I created two random arrays in NumPy and then I used x and y in model.fit() but I got this error:
Node: 'sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits' logits and labels must have the same first dimension, got logits shape [3,3] and labels shape [33] [[{{node sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits}}]] [Op:__inference_train_function_6412]
What does this error mean?
Code:
import numpy as np
import pandas as pd
import tensorflow as tf
from tensorflow import keras
from tensorflow.keras import layers
import numpy
x=np.random.randint(40,100,33).reshape(3, 11)
y=np.random.randint(44,66,33).reshape(3, 11)
model = keras.Sequential(
[
layers.Dense(3, activation="relu", name="layer1"),
layers.Dense(3, activation="relu", name="layer2"),
layers.Dense(3, name="layer3"),
]
)
# Call model on a test input
model.compile(optimizer=keras.optimizers.Adam(learning_rate=.0001),loss='sparse_categorical_crossentropy',metrics=['accuracy'])
model.fit(x,y,batch_size=10,epochs=5,verbose=2)

