def resize_cast(x, shape): H, W, C = shape x = x.reshape(-1, 28, 28, 3) resized_x = np.empty((len(x), H, W, 3), dtype='float32') for i, img in enumerate(x): # imresize returns uint8 resized_x[i] = u2t(scipy.misc.imresize(img, (H, W))) return resized_x
def __init__(self): print('load Simg...') trainx = np.load(args.datadir + 'trainX.npy') trainy = np.load(args.datadir + 'trainY.npy') trainx = u2t(trainx).astype('float32') trainy = np.eye(10)[trainy].astype('float32') self.train = Data(trainx[:4000], trainy[:4000], cast=True) self.test = Data(trainx[4000:], trainy[4000:], casts=True)
def preprocess(self, x): if self.cast: return u2t(x) else: return x