title: ValueError when fitting keras model
body: <p>I have the <a href="https://colab.research.google.com/drive/1133qU63WE_WrW1SFwzz532mjb4xeMV23?usp=sharing" rel="nofollow noreferrer">following code</a>:</p>
  <pre><code>from sklearn.datasets import fetch_openml
  import numpy as np
  import keras
  
  mnist = fetch_openml('mnist_784', version=1)   
  X, y = mnist[&quot;data&quot;], mnist[&quot;target&quot;]
  
  y = y.astype(np.uint8)
  
  X_digits = [np.array(X.iloc[i]) for i in range(len(X))]
  X = np.array([some_digit.reshape(28, 28) for some_digit in X_digits])
  
  X_train, X_test, y_train, y_test = X[:60000], X[60000:], y[:60000], y[60000:]
  
  model = keras.models.Sequential([
      keras.layers.Conv2D(64, 7, activation=&quot;relu&quot;, padding=&quot;same&quot;,
                          input_shape=[28, 28, 1]),
      keras.layers.MaxPooling2D(2),
      keras.layers.Conv2D(128, 3, activation=&quot;relu&quot;, padding=&quot;same&quot;),
      keras.layers.Conv2D(128, 3, activation=&quot;relu&quot;, padding=&quot;same&quot;),
      keras.layers.MaxPooling2D(2),
      keras.layers.Conv2D(256, 3, activation=&quot;relu&quot;, padding=&quot;same&quot;),
      keras.layers.Conv2D(256, 3, activation=&quot;relu&quot;, padding=&quot;same&quot;),
      keras.layers.MaxPooling2D(2),
      keras.layers.Flatten(),
      keras.layers.Dense(128, activation=&quot;relu&quot;),
      keras.layers.Dropout(0.5),
      keras.layers.Dense(64, activation=&quot;relu&quot;),
      keras.layers.Dropout(0.5),
      keras.layers.Dense(10, activation=&quot;softmax&quot;)
  ])
  
  model.compile(loss=&quot;categorical_crossentropy&quot;)
  </code></pre>
  <p>That all seems to work fine.  But then on this line:</p>
  <pre><code>model.fit(X_train, y_train)
  </code></pre>
  <p>I get this error:</p>
  <pre><code>ValueError                                Traceback (most recent call last)
  &lt;ipython-input-19-d768f88d541e&gt; in &lt;module&gt;()
  ----&gt; 1 model.fit(X_train, y_train)
  
  1 frames
  /usr/local/lib/python3.7/dist-packages/tensorflow/python/framework/func_graph.py in autograph_handler(*args, **kwargs)
     1127           except Exception as e:  # pylint:disable=broad-except
     1128             if hasattr(e, &quot;ag_error_metadata&quot;):
  -&gt; 1129               raise e.ag_error_metadata.to_exception(e)
     1130             else:
     1131               raise
  
  ValueError: in user code:
  
      File &quot;/usr/local/lib/python3.7/dist-packages/keras/engine/training.py&quot;, line 878, in train_function  *
          return step_function(self, iterator)
      File &quot;/usr/local/lib/python3.7/dist-packages/keras/engine/training.py&quot;, line 867, in step_function  **
          outputs = model.distribute_strategy.run(run_step, args=(data,))
      File &quot;/usr/local/lib/python3.7/dist-packages/keras/engine/training.py&quot;, line 860, in run_step  **
          outputs = model.train_step(data)
      File &quot;/usr/local/lib/python3.7/dist-packages/keras/engine/training.py&quot;, line 810, in train_step
          y, y_pred, sample_weight, regularization_losses=self.losses)
      File &quot;/usr/local/lib/python3.7/dist-packages/keras/engine/compile_utils.py&quot;, line 201, in __call__
          loss_value = loss_obj(y_t, y_p, sample_weight=sw)
      File &quot;/usr/local/lib/python3.7/dist-packages/keras/losses.py&quot;, line 141, in __call__
          losses = call_fn(y_true, y_pred)
      File &quot;/usr/local/lib/python3.7/dist-packages/keras/losses.py&quot;, line 245, in call  **
          return ag_fn(y_true, y_pred, **self._fn_kwargs)
      File &quot;/usr/local/lib/python3.7/dist-packages/keras/losses.py&quot;, line 1665, in categorical_crossentropy
          y_true, y_pred, from_logits=from_logits, axis=axis)
      File &quot;/usr/local/lib/python3.7/dist-packages/keras/backend.py&quot;, line 4994, in categorical_crossentropy
          target.shape.assert_is_compatible_with(output.shape)
  
      ValueError: Shapes (32, 1) and (32, 10) are incompatible
  </code></pre>
  <p>What is going wrong here?</p>