title: Custom training with my own images using tf.data
body: <p>I'm new to tensorflow and I have trouble with feeding my custom data to keras model.</p>
  
  <p>I've followed this guide:<a href="https://www.tensorflow.org/tutorials/load_data/images" rel="nofollow noreferrer">Load images</a> to convert my .jpg files to tf.data.</p>
  
  <p>Now I have my data converted to (image_batch, label_batch). The image_batch is EagerTensor with shape (32,224,224,3) and the label_batch is EagerTensor with shape (32,2).</p>
  
  <p>Then I found this guide:<a href="https://www.tensorflow.org/tutorials/customization/custom_training_walkthrough" rel="nofollow noreferrer">Custom training: walkthrough</a> but the data in the guild is converted to EagerTensor with shape (32,4).</p>
  
  <p>I got Warning when executing the code:</p>
  
  <pre><code>model = tf.keras.Sequential([
    tf.keras.layers.Dense(10, activation=tf.nn.relu, input_shape=(3,)),  # input shape required
    tf.keras.layers.Dense(10, activation=tf.nn.relu),
    tf.keras.layers.Dense(3)
  ])
  </code></pre>
  
  <pre><code>predictions = model(image_batch)
  </code></pre>
  
  <pre><code>WARNING:tensorflow:Model was constructed with shape (None, 3) for input Tensor("dense_input:0", shape=(None, 3), dtype=float32), but it was called on an input with incompatible shape (32, 224, 224, 3).
  </code></pre>
  
  <p>How should I adjust my model or what should I do with my data?</p>
  
  <h2>EDIT:</h2>
  
  <p>The model now works, but with one additional problem.</p>
  
  <p>When I run the following code:</p>
  
  <pre><code>print("Prediction: {}".format(tf.argmax(predictions, axis=1)))
  print("    Labels: {}".format(labels_batch))
  </code></pre>
  
  <p>it prints:</p>
  
  <pre><code>Prediction: [1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1]
      Labels: [[ True False]
   [False  True]
   [ True False]
   [False  True]
   [ True False]...(omitted)]
  </code></pre>
  
  <p>But I expected it prints something like:</p>
  
  <pre><code>Prediction: [0 1 0 1 1 1 0 1 0 1 1 0 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0 1 0 0 1 0]
      Labels: [2 0 2 0 0 0 1 0 2 0 0 1 1 2 2 2 1 0 1 0 1 2 0 1 1 1 1 0 2 2 0 2]
  </code></pre>
  
  <p>with Labels as a one dimensional array with integers.</p>
  
  <p>I wonder if it is normal that the predictions are all 1? What should I do?</p>