---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-37-9a9cd8046c6f> in <cell line: 18>()
16 loss=tf.keras.losses.CategoricalCrossentropy(),
17 metrics=['accuracy'])
---> 18 history1=model1.fit(train_data,epochs=5,validation_data=valid_data)
1 frames
/usr/local/lib/python3.10/dist-packages/keras/src/backend/tensorflow/nn.py in categorical_crossentropy(target, output, from_logits, axis)
552 )
553 if len(target.shape) != len(output.shape):
--> 554 raise ValueError(
555 "Arguments `target` and `output` must have the same rank "
556 "(ndim). Received: "
ValueError: Arguments `target` and `output` must have the same rank (ndim). Received: target.shape=(None,), output.shape=(None, 19)
So in this, I don’t understand what the problem is ??
But when I train my model with SpareCategoricalCrossentropy, then it’s just working fine, but is giving a very bad accuracy and in the valid data it’s zero
I tried to use SpareCategorical, yet the accuracy was very low. See my dataset is from kaggle, so I just downloaded it gave it an image size
train_dir="Dataset/train/" test_dir="Dataset/test/" train_data= Images(train_dir,image_size=(150,150),batch_size=32) valid_data= Images(test_dir,image_size=(150,150),batch_size=32)
And I rescalled this. Now can anyone tell me what should I do ??
karan10i is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.