Facing issue C3_W2 assignment

last layer Dens(units=5, activation=‘softmax’)
I am using loss='categorical_crossentropy
optimizer=‘adam’

getting below error . please help me asap
File “/opt/conda/lib/python3.8/site-packages/keras/engine/training.py”, line 878, in train_function *
return step_function(self, iterator)
File “/opt/conda/lib/python3.8/site-packages/keras/engine/training.py”, line 867, in step_function **
outputs = model.distribute_strategy.run(run_step, args=(data,))
File “/opt/conda/lib/python3.8/site-packages/keras/engine/training.py”, line 860, in run_step **
outputs = model.train_step(data)
File “/opt/conda/lib/python3.8/site-packages/keras/engine/training.py”, line 809, in train_step
loss = self.compiled_loss(
File “/opt/conda/lib/python3.8/site-packages/keras/engine/compile_utils.py”, line 201, in call
loss_value = loss_obj(y_t, y_p, sample_weight=sw)
File “/opt/conda/lib/python3.8/site-packages/keras/losses.py”, line 141, in call
losses = call_fn(y_true, y_pred)
File “/opt/conda/lib/python3.8/site-packages/keras/losses.py”, line 245, in call **
return ag_fn(y_true, y_pred, **self._fn_kwargs)
File “/opt/conda/lib/python3.8/site-packages/keras/losses.py”, line 1664, in categorical_crossentropy
return backend.categorical_crossentropy(
File “/opt/conda/lib/python3.8/site-packages/keras/backend.py”, line 4994, in categorical_crossentropy
target.shape.assert_is_compatible_with(output.shape)

ValueError: Shapes (None, 1) and (None, 5) are incompatible

Hello @Abhisekh_Agarwala1,

Can I know what loss are you using?

You seem to be using categorical cross entropy, which is incorrect

use the ‘sparse_categorical_crossentropy’

Regards
DP