from framework.utils import serial from framework.datasets import cifar10 from framework.datasets import preprocessing train = cifar10.CIFAR10(which_set="train") pipeline = preprocessing.Pipeline() pipeline.items.append( preprocessing.ExtractPatches(patch_shape=(8, 8), num_patches=150000)) pipeline.items.append(preprocessing.GlobalContrastNormalization()) pipeline.items.append(preprocessing.ZCA()) test = cifar10.CIFAR10(which_set="test") train.apply_preprocessor(preprocessor=pipeline, can_fit=True) test.apply_preprocessor(preprocessor=pipeline, can_fit=False) train.use_design_loc('cifar10_preprocessed_train_design.npy') test.use_design_loc('cifar10_preprocessed_test_design.npy') serial.save('cifar10_preprocessed_train.pkl', train) serial.save('cifar10_preprocessed_test.pkl', test)
from framework.utils import serial from framework.datasets import cifar10 from framework.datasets import preprocessing train = cifar10.CIFAR10(which_set="train") pipeline = preprocessing.Pipeline() pipeline.items.append(preprocessing.ExtractPatches(patch_shape=(8,8),num_patches=200000)) pipeline.items.append(preprocessing.GlobalContrastNormalization()) pipeline.items.append(preprocessing.ZCA()) train.apply_preprocessor(preprocessor = pipeline, can_fit = True) serial.save('preprocessor.pkl',pipeline)
def __init__(self, which_set): self.underlying = cifar10.CIFAR10(which_set = which_set) self.preprocessor = serial.load('/u/goodfeli/framework/recons_srbm/cifar10_preprocessor_2M.pkl')