hi i have the following code
model = tf.keras.Sequential()
model.add(tf.keras.layers.LSTM(64, return_sequences=True, recurrent_regularizer=l2(0.0015),
input_shape=(timesteps, input_dim)))
model.add(tf.keras.layers.LSTM(64, return_sequences=True, recurrent_regularizer=l2(0.0015),
input_shape=(timesteps, input_dim)))
model.add(tf.keras.layers.Dense(64, activation='relu'))
model.add(tf.keras.layers.Dense(n_classes, activation='softmax'))
model.summary()
model.compile(optimizer=Adam(learning_rate = 0.0025), loss = 'sparse_categorical_crossentropy',
metrics = ['accuracy'])
model.fit(X_train, y_train, batch_size=64, epochs=10),
why do I get this error
InvalidArgumentError: assertion failed: [Condition x == y did not hold element-wise:] [x
(sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/Shape_1:0) = ] [64 1] [y
(sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/strided_slice:0) = ] [64 100]
[[node
sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/assert_equal_1/Assert/Assert
(defined at <ipython-input-37-7217e69c04b0>:15) ]] [Op:__inference_train_function_22603]
Function call stack:
train_function
when I run the following the code executes fine
model = Sequential()
model.add(LSTM(64, return_sequences=True, recurrent_regularizer=l2(0.0015),
input_shape=(timesteps, input_dim)))
model.add(Dropout(0.5))
model.add(LSTM(64, recurrent_regularizer=l2(0.0015), input_shape=
(timesteps,input_dim)))
model.add(Dense(64, activation='relu'))
model.add(Dense(64, activation='relu'))
model.add(Dense(n_classes, activation='softmax'))
model.summary()
model.compile(optimizer=Adam(learning_rate = 0.0025), loss =
'sparse_categorical_crossentropy', metrics = ['accuracy'])
model.fit(X_train, y_train, batch_size=32, epochs=1)
i am using tensorflow 2.2.0. why then is the error raised. Has to do with the batch size?