title: Tensorflow error : Dimensions must be equal
body: <p>I have a dataset of 25000 colored pictures 100*100(*3) and I am trying to build a simple neural network with one convolutional layer. Its pictures of cells that are infected or not by Malaria, so my output is 2.
  But it seems like I have a dimension mismatch, and I don't know where my error comes from. </p>
  
  <p>My neural network : </p>
  
  <pre><code>def simple_nn(X_training, Y_training, X_test, Y_test):
      input = 100*100*3
      batch_size = 25
  
      X = tf.placeholder(tf.float32, [batch_size, 100, 100, 3])
      #Was:
      # W = tf.Variable(tf.zeros([input, 2]))
      # b = tf.Variable(tf.zeros([2]))
      #Now:
      W = tf.Variable(tf.truncated_normal([4, 4, 3, 3], stddev=0.1))
      B = tf.Variable(tf.ones([3])/10) # What should I put here ??
  
      init = tf.global_variables_initializer()
  
      # model
      #Was:
      # Y = tf.nn.softmax(tf.matmul(tf.reshape(X, [-1, input]), W) + b)
      #Now:
      stride = 1  # output is still 28x28
      Ycnv = tf.nn.conv2d(X, W, strides=[1, stride, stride, 1], padding='SAME')
      Y = tf.nn.relu(Ycnv + B)
  
      # placeholder for correct labels
      Y_ = tf.placeholder(tf.float32, [None, 2])
  
  
      # loss function
      cross_entropy = -tf.reduce_sum(Y_ * tf.log(Y))
  
      # % of correct answers found in batch
      is_correct = tf.equal(tf.argmax(Y,1), tf.argmax(Y_,1))
      accuracy = tf.reduce_mean(tf.cast(is_correct, tf.float32))
  
      learning_rate = 0.00001
  
      optimizer = tf.train.GradientDescentOptimizer(learning_rate)
      train_step = optimizer.minimize(cross_entropy)
      sess = tf.Session()
      sess.run(init)
      #Training here...
  </code></pre>
  
  <p>My error : </p>
  
  <pre><code>Traceback (most recent call last):
    File "neural_net.py", line 135, in &lt;module&gt;
      simple_nn(X_training, Y_training, X_test, Y_test)
    File "neural_net.py", line 69, in simple_nn
      cross_entropy = -tf.reduce_sum(Y_ * tf.log(Y))
  ...
  ValueError: Dimensions must be equal, but are 2 and 3 for 'mul' (op: 'Mul') with input shapes: [?,2], [25,100,100,3].
  </code></pre>
  
  <p>I used a simple layer before, and it was working. I changed my weight and bias, and honestly, I don't know why my bias are setup like this, I followed a tutorial (<a href="https://codelabs.developers.google.com/codelabs/cloud-tensorflow-mnist/#11" rel="nofollow noreferrer">https://codelabs.developers.google.com/codelabs/cloud-tensorflow-mnist/#11</a>) but it is not explained.
  I also replaced my Y to a conv2D.
  And I don't know what my ouput should be if I want to get a vector of size 2*1 as a result.</p>