I am learning deep learning with tensorflow. I made a simple NLP code predicting the next word on a given sentence
model = tf.keras.Sequential()
model.add(Embedding(num,64,input_length = max_len-1)) # we subtract 1 coz we cropped the laste word from X in out data
model.add(Bidirectional(LSTM(32)))
model.add(Dense(num,activation = 'softmax'))
model.compile(optimizer = 'adam',loss = 'categorical_crossentropy',metrics = ['accuracy'])
history = model.fit(X,Y,epochs = 500)
however using categorical_crossentropy gives me the following error
ValueError: You are passing a target array of shape (453, 1) while using as loss `categorical_crossentropy`. `categorical_crossentropy` expects targets to be binary matrices (1s and 0s) of shape (samples, classes). If your targets are integer classes, you can convert them to the expected format via:
```
from keras.utils import to_categorical
y_binary = to_categorical(y_int)
```
Alternatively, you can use the loss function `sparse_categorical_crossentropy` instead, which does expect integer targets.
Can someone explain me what does this mean and why i cant use categorical crossentropy loss function? Thank you so much! Any help would be appreciated!