Incompatible Shapes On Tensorflow
I am new in CNN,I am trying to make a CNN to classify image data set of handwritten English alphabet(a-z),(A-Z) and numbers (0-9),which have 62 labels.Each image size is 30*30 pixe
Solution 1:
I change the dimensions of the input to the fully connected layer from 4 to 8,its working now
W_fc1 = weight_variable([8 * 8 * 64, 1024])
b_fc1 = bias_variable([1024])
#the input should be shaped/flattenedh_pool2_flat = tf.reshape(h_pool2, [-1, 8*8*64])
h_fc1 = tf.nn.relu(tf.matmul(h_pool2_flat, W_fc1) + b_fc1)
Solution 2:
Take a look at these lines of code:
cross_entropy = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=y_, logits=y_conv))
correct_prediction = tf.equal(tf.argmax(y_conv,1), tf.argmax(y_,1))
If labels is a list with the index of the correct prediction (for example: [1,32,13, ...]
) the softmax_cross_entropy_with_logits
function is correct. This means that the error is in these lines. I put in a comment that they do:
tf.argmax(y_conv,1) # Takes the max index of logits
tf.argmax(y_,1) # Takes the max index of ???.
Although I did not test it, replacing it with this line should work:
correct_prediction = tf.equal(tf.argmax(y_conv,1), y_)
Let me know when you fixed it :D
Post a Comment for "Incompatible Shapes On Tensorflow"