I use X and y data (which are both np arrays) with the following shape:
print(X.shape)
print(y.shape)
(1075, 5, 50)
(1075, 5)
The model:
# define the keras model
model = Sequential()
model.add(Dense(512, input_shape=(5, 50), activation='relu'))
model.add(Dense(64, activation='relu'))
model.compile(loss='categorical_crossentropy', optimizer="Adam", metrics=['accuracy'])
history = model.fit(X, y, epochs=100, batch_size=10, validation_split=0.2)
And i get the following error:
ValueError
Traceback (most recent call last)
Cell In[79], line 1
----> 1 history = model.fit(X, y, epochs=100, batch_size=10, validation_split=0.2, callbacks=[callback])
ValueError: Shapes (10, 5) and (10, 5, 64) are incompatible
If I change the last layers density from 64 to 10, the error ouput changes:
model.add(Dense(10, activation='relu'))
ValueError: Shapes (10, 5) and (10, 5, 10) are incompatibl
To what dimension do i have to chnage my last layer, so it fits to the shape of my y data?