I'm using tensorboard to visualize my train images(cifar10 dataset). But the TensorBoard shows me some very strange images. Below is the screenshot.
Here is some relative code. Note that DISPLAY_STEP
is 10, BATCH_SIZE
is 64.
x = tf.placeholder(tf.float32, shape=[None, N_FEATURES], name='x')
x_image = tf.reshape(x, [-1, 32, 32, 3])
tf.summary.image('input', x_image, max_outputs=BATCH_SIZE)
y = tf.placeholder(tf.float32, [None, N_CLASSES], name='labels')
'''There is other code.'''
with tf.Session() as sess:
sess.run(init)
summary_writer = tf.summary.FileWriter('./cifar10_model/6', graph=tf.get_default_graph())
for i in range(TRAINING_EPOCHS):
batch_x, batch_y = cifar10.train.next_batch(BATCH_SIZE)
if i % DISPLAY_STEP == 0:
s = sess.run(merged_summary, feed_dict={x: batch_x, y: batch_y})
summary_writer.add_summary(s, i)
sess.run(train_step, feed_dict={x: batch_x, y: batch_y})
Could anyone tell me what's going on? Thanks in advance.
It looks like the cifar images are not reshaped properly. According to the dataset website:
data -- a 10000x3072 numpy array of uint8s. Each row of the array stores a 32x32 colour image. The first 1024 entries contain the red channel values, the next 1024 the green, and the final 1024 the blue. The image is stored in row-major order, so that the first 32 entries of the array are the red channel values of the first row of the image.
You should make sure this 3072 long array is reshaped properly.