TensorFlow 2.0 output specification in NLP model I just started playing with TensorFlow 2.0 now that the new api is out. However, I do not get the model output specification. 
The model below is a simple example from their site with the mnistdataset. If I understand correctly, there are 60000 images (28x28) pixels. Each input image has one corresponding digit (0-9) output.    
import tensorflow as tf

mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()
x_train, x_test = x_train / 255.0, x_test / 255.0

print(y_train.shape) # <-- output dimension (60000,) 

model = tf.keras.models.Sequential([
  tf.keras.layers.Flatten(input_shape=(28, 28)),
  tf.keras.layers.Dense(128, activation='relu'),
  tf.keras.layers.Dropout(0.2),
  tf.keras.layers.Dense(10, activation='softmax') # <-- output nodes 10 
])

model.compile(optimizer='adam',
              loss='sparse_categorical_crossentropy',
              metrics=['accuracy'])

model.fit(x_train, y_train, batch_size=5, epochs=5)
model.evaluate(x_test, y_test)

Note from the print out, we have one dimensional training array i.e.:(60000,) but in the last layer we specify 10 nodes! Why? I understand why 10 nodes if the output was one_hot'ed - but as shown we have a single digit. 
If someone can explain whats going on here - I would really appreciate it. 
 A: This works because the model uses the sparse_categorical_crossentropy loss function. It is like a regular categorical crossentropy loss that doesn't require the labels to be one-hot encoded to work!
Alternatively you could one-hot encode the labels and train on a categorical_crossentropy loss:
import tensorflow as tf

mnist = tf.keras.datasets.mnist
(x_train, y_train), (x_test, y_test) = mnist.load_data()

# One-hot encode the labels
y_train = tf.keras.utils.to_categorical(y_train, 10)
y_test = tf.keras.utils.to_categorical(y_test, 10)

x_train, x_test = x_train / 255.0, x_test / 255.0

print(y_train.shape) # <-- output dimension (60000, 10) 

model = tf.keras.models.Sequential([
  tf.keras.layers.Flatten(input_shape=(28, 28)),
  tf.keras.layers.Dense(128, activation='relu'),
  tf.keras.layers.Dropout(0.2),
  tf.keras.layers.Dense(10, activation='softmax') # <-- output nodes 10 
])

model.compile(optimizer='adam',
              loss='categorical_crossentropy',  # <-- changed loss function
              metrics=['accuracy'])

model.fit(x_train, y_train, batch_size=5, epochs=5)  # still works
model.evaluate(x_test, y_test)

