I am new to keras and I have a problem with a model with more than one dimension. So, I tried some samples. This is one of them.
from keras.models import Sequential
from keras.layers import Dense
import numpy as np
X_train = np.array([[[1, 2], [3, 4]], [[1, 2], [3, 4]]])
model = Sequential([
Dense(32, input_shape=X_train.shape[1:]),
])
model.compile(loss='sparse_categorical_crossentropy', optimizer='sgd')
model.fit(X_train, [1, 2])
I expect the above sample to run, but I get an error
Error when checking target: expected dense_1 to have 3 dimensions, but got array with shape (2, 1)
What is the reason for this. Can someone give an example on how to run the keras model using multidimensional input, i.e. How to structure the input? Thank.
source
share