Skip to content

Commit 39e2f5f

Browse files
committed
cifar preprocess
1 parent 3c5e972 commit 39e2f5f

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

main.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,10 @@ def train(conf, data):
7575
from keras.datasets import cifar10
7676
data = cifar10.load_data()
7777
labels = data[0][1]
78-
data = data[0][0] / 255.0
78+
data = data[0][0].astype(np.float32)
79+
data[:,0,:,:] -= np.mean(data[:,0,:,:])
80+
data[:,1,:,:] -= np.mean(data[:,1,:,:])
81+
data[:,2,:,:] -= np.mean(data[:,2,:,:])
7982
data = np.transpose(data, (0, 2, 3, 1))
8083
conf.img_height = 32
8184
conf.img_width = 32

models.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def __init__(self, X, conf, h=None):
6464
the 2 methods which may be used, with the first one (self.pred)
6565
being more likely.
6666
'''
67-
self.pred = tf.reshape(tf.multinomial(tf.nn.softmax(self.fc2), num_samples=1, seed=100), tf.shape(self.X))
68-
self.pred_argmax = tf.reshape(tf.argmax(tf.nn.softmax(self.fc2), dimension=tf.rank(self.fc2) - 1), tf.shape(self.X))
67+
self.pred_sampling = tf.reshape(tf.multinomial(tf.nn.softmax(self.fc2), num_samples=1, seed=100), tf.shape(self.X))
68+
self.pred = tf.reshape(tf.argmax(tf.nn.softmax(self.fc2), dimension=tf.rank(self.fc2) - 1), tf.shape(self.X))
6969

7070

7171
class ConvolutionalEncoder(object):

0 commit comments

Comments
 (0)