title: Keras: Trying to model.predict() gives "ValueError: Tensor's shape is not compatible with supplied shape"
body: <p>I'm following <a href="https://www.tensorflow.org/tutorials/text/text_generation" rel="nofollow noreferrer">the TensorFlow Keras tutorial for text generation</a>. The training part works perfectly, but when I try to predict the next token, I get an error.
  Here's all the important code:</p>
  
  <ol>
  <li><strong>Making the vocabulary and dataset.</strong></li>
  </ol>
  
  <pre><code>vocab = sorted(set(text))
  
  char2index = { c:i for i, c in enumerate(vocab) }
  index2char = np.array(vocab)
  chars_to_int = np.array([char2index[c] for c in text])
  
  char_dataset = tf.data.Dataset.from_tensor_slices(chars_to_int)
  sequences = char_dataset.batch(seq_length + 1, drop_remainder=True)
  
  def split_input_and_target(sequence):
      input_ = sequence[:-1]
      target_ = sequence[1:]
      return input_, target_
  
  dataset = sequences.map(split_input_and_target)
  dataset = dataset.shuffle(BUFFER_SIZE).batch(BATCH_SIZE, drop_remainder=True)
  </code></pre>
  
  <ol start="2">
  <li><strong>Building the model</strong>
  (important part here is that BATCH_SIZE = 64):</li>
  </ol>
  
  <pre><code>model = tf.keras.Sequential()
  
  model.add(tf.keras.layers.Embedding(len(vocab), EMBEDDING_DIM,
                      batch_input_shape=[BATCH_SIZE, None]))
  # here are a few more layers
  
  model.compile(loss="sparse_categorical_crossentropy", optimizer="adam")
  model.fit(dataset, epochs=EPOCHS)
  </code></pre>
  
  <ol start="3">
  <li><strong>Actually trying to generate text</strong> (this one was copied almost directly from the tutorial after I started getting desperate):</li>
  </ol>
  
  <pre><code>num_tokens = 100
  seed = "some text"
  input_eval = [char2index[c] for c in seed]
  input_eval = tf.expand_dims(input_eval, 0)
  text_generated = []
  
  model.reset_states()
  
  for i in range(num_tokens):
      predictions = model(input_eval)
      predictions = tf.squeeze(predictions, 0)
      # more stuff
  </code></pre>
  
  <p>Then, I first get a warning:</p>
  
  <pre><code>WARNING:tensorflow:Model was constructed with shape (64, None) for input Tensor("embedding_14_input:0", shape=(64, None), dtype=float32), but it was called on an input with incompatible shape (1, 9).
  </code></pre>
  
  <p>Then it gives me an error:</p>
  
  <pre><code>----&gt;3     predictions = model(input_eval)
  ...
  ValueError: Tensor's shape (9, 64, 256) is not compatible with supplied shape [9, 1, 256]
  </code></pre>
  
  <p>The second number, 64, is my batch size. If I change BATCH_SIZE to 1, everything works and all is fine, but this is obviously not the solution I am hoping for.</p>