title: Why do I get "logits and labels must have the same shape" error?
body: <p>I have the following piece of code, which is a <strong>simplification</strong> of my actual code:</p>
  <pre><code>#!/usr/bin/env python3
  
  import tensorflow as tf
  import re
  import numpy as np
  import pandas as pd
  from tensorflow.keras.preprocessing.text import Tokenizer #text to vector.
  from keras.layers import Dense, Embedding, LSTM, SpatialDropout1D
  from keras.models import Sequential
  
  DATASIZE = 1000
  
  model = Sequential()
  model.add(Embedding(1000, 120, input_length = DATASIZE))
  model.add(SpatialDropout1D(0.4))
  model.add(LSTM(176, dropout=0.2, recurrent_dropout=0.2))
  model.add(Dense(2,activation='sigmoid'))
  model.compile(loss = 'binary_crossentropy', optimizer='adam', metrics = ['accuracy'])
  print(model.summary())
  
  training = [[0 for x in range(10)] for x in range (DATASIZE)] #random value
  label = [[1 for x in range(10)] for x in range (DATASIZE)]    #random value
  model.fit(training, label, epochs = 5, batch_size=32, verbose = 'auto')
  </code></pre>
  <p>What I need:</p>
  <p>My endgoal is to be able to check whether a given input vector (which is a numerical representation of data) is positive or negative, so it is a binary classification issue here. Here all the 1000 vectors are 10 digits long, but it could be waay longer or even much shorter, <strong>length might vary throughout the dataset</strong>.</p>
  <p>When running this I get the following error:</p>
  <pre><code>ValueError: logits and labels must have the same shape ((None, 2) vs (None, 10))
  </code></pre>
  <p>How do I have to structure my vectors in order to not get this error and actually <strong>correctly</strong> fit the model?</p>
  <p><strong>EDIT:</strong>
  I could change the <code>model.add(Dense(2,activation='sigmoid'))</code> call to <code>model.add(Dense(10,activation='sigmoid'))</code>. But this doesn't make much sense, I think. As the first parameter of Dense is the actual number of output possibilities. In my case there are only 2 possibilities: positive or negative. So rnndomly changing this to 10, makes the program run, but doesn't make sense to me. And I am not even sure it is using my 1000 training vectors....</p>