title: InvalidArgumentError: logits and labels must have the same first dimension, got logits shape [1,10] and labels shape [40]
body: <p>I'm using Keras-Tuner to auto-identify the best parameters for my CNN. I am using Celeb_a dataset.</p>
  <p>you can find the code I am using <a href="https://bitbucket.org/mrjeancamargo1/keras-tuner1/src/master/CelebA_Tuner.py" rel="nofollow noreferrer">here</a>
  When I try to run it I get the error below.</p>
  <blockquote>
  <p>InvalidArgumentError:  logits and labels must have the same first
  dimension, got logits shape [1,10] and labels shape [40]
  [[node sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits
  (defined at
  C:\Users\admin-sepr\anaconda3\envs\tf\lib\site-packages\kerastuner\engine\tuner.py:141)
  ]] [Op:__inference_train_function_953]</p>
  </blockquote>
  <p>I have seen in other places that this could be down to using <code>loss=&quot;categorical_crossentropy&quot;,</code> when I compile the code and they recomended to try <code>loss=&quot;sparse_categorical_crossentropy&quot;,</code> instead.</p>
  <p>when I do this I get the following error.</p>
  <blockquote>
  <p>InvalidArgumentError:  logits and labels must be broadcastable:
  logits_size=[64,380192] labels_size=[64,40]    [[node
  categorical_crossentropy/softmax_cross_entropy_with_logits (defined at
  C:\Users\admin-sepr\anaconda3\envs\tf\lib\site-packages\kerastuner\engine\tuner.py:141)
  ]] [Op:__inference_train_function_6830]</p>
  </blockquote>
  <p>The function call stack is the following for both errors.</p>
  <pre><code>Function call stack:
  train_function
  </code></pre>
  <p>My function train_function goes as following (full code available above):</p>
  <pre><code>train_generator = train_datagen.flow_from_dataframe(
                                          dataframe=train_split,
                                          directory=celeba.images_folder,
                                          x_col='image_id',
                                          y_col=celeba.features_name,
                                          target_size=TARGET_SIZE,
                                          batch_size=64,
                                          class_mode='raw',
                                          dtype=tf.float32)
  </code></pre>
  <p>I tried the recommended in <a href="https://stackoverflow.com/questions/51591550/logits-and-labels-must-be-broadcastable-error-in-tensorflow-rnn">here</a> but didnt get any success.</p>