Slide 25
Slide 25 text
ྫɿࣙॻֶशͱ࠶ߏ
#
patches = extract_simple_patches_2d(img, patch_size)
#
patches = patches.reshape(patches.shape[0], -1).astype(np.float64)
intercept = np.mean(patches, axis=0)
patches -= intercept
patches /= np.std(patches, axis=0)
#
model = MiniBatchDictionaryLearning(n_components=n_basis, alpha=1,
n_iter=n_iter, n_jobs=1)
model.fit(patches)
#
reconstructed_patches = np.dot(code, model.components_)
reconstructed_patches = reconstructed_patches.reshape(len(patches),
*patch_size)
reconstructed = reconstruct_from_simple_patches_2d(reconstructed_patches,
img.shape)