From 39e2f5f6b49be01604b69bd5d33a850c5512a403 Mon Sep 17 00:00:00 2001 From: Anant Gupta Date: Wed, 30 Nov 2016 18:54:11 +0530 Subject: [PATCH] cifar preprocess --- main.py | 5 ++++- models.py | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 8cad634..905e60f 100644 --- a/main.py +++ b/main.py @@ -75,7 +75,10 @@ def train(conf, data): from keras.datasets import cifar10 data = cifar10.load_data() labels = data[0][1] - data = data[0][0] / 255.0 + data = data[0][0].astype(np.float32) + data[:,0,:,:] -= np.mean(data[:,0,:,:]) + data[:,1,:,:] -= np.mean(data[:,1,:,:]) + data[:,2,:,:] -= np.mean(data[:,2,:,:]) data = np.transpose(data, (0, 2, 3, 1)) conf.img_height = 32 conf.img_width = 32 diff --git a/models.py b/models.py index e4b4eeb..8d97eeb 100644 --- a/models.py +++ b/models.py @@ -64,8 +64,8 @@ def __init__(self, X, conf, h=None): the 2 methods which may be used, with the first one (self.pred) being more likely. ''' - self.pred = tf.reshape(tf.multinomial(tf.nn.softmax(self.fc2), num_samples=1, seed=100), tf.shape(self.X)) - self.pred_argmax = tf.reshape(tf.argmax(tf.nn.softmax(self.fc2), dimension=tf.rank(self.fc2) - 1), tf.shape(self.X)) + self.pred_sampling = tf.reshape(tf.multinomial(tf.nn.softmax(self.fc2), num_samples=1, seed=100), tf.shape(self.X)) + self.pred = tf.reshape(tf.argmax(tf.nn.softmax(self.fc2), dimension=tf.rank(self.fc2) - 1), tf.shape(self.X)) class ConvolutionalEncoder(object):