In Machine Learning Specialization taught by Ng. Adrew, **most Neural network models for multiclass classification use SparseCategoricalCrossentropy**. For example, in a neural network to recognize ten handwritten digits, 0-9, the code is as follows:

model.compile( loss=tf.keras.losses.SparseCategoricalCrossentropy,

optimizer = tf.keras.optimizers.Adam(0.001),

)

**I was considering using CategoricalCrossentropy for this handwritten digit recognition example to see the differences in outcomes. However, there is a error that says ‘ValueError: Shapes (None, 1) and (None, 10) are incompatible’**

**So, is it possible to use the CategoricalCrossentropy loss function in this case? What are the differences between SparseCategoricalCrossentropy and CategoricalCrossentropy in TensorFlow?**

Remark: CategoricalCrossEntropy: Expects the target value of an example to be one-hot encoded where the value at the target index is 1 while the other N-1 entries are zero. An example with 10 potential target values, where the target is 2 would be [0,0,1,0,0,0,0,0,0,0].