示例#1
0
    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
示例#2
0
    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
示例#3
0
    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)
示例#4
0
 def preprocess(self, x):
     if self.cast:
         return u2t(x)
     else:
         return x
示例#5
0
 def preprocess(self, x):
     if self.cast:
         return u2t(x)
     else:
         return x