I am trying to pass my neural network an array with shape with shape (1169909, 10, 10).
But no matter what I do...
input_shape=(None,10,10)
input_shape=x_train.shape[1:]
input_shape=x_train.shape
input_shape=(1169909, 1)
input_shape=(10,10)
input_shape=(1169909,10)
input_shape=(1169909,10,10)
input_shape=(1,10,10)
I still get an error. The error changes:
but got array with shape (1169909, 10, 10)
but got array with shape (1169909, 1)
Depending on which way I give the input, which only adds to my confusion.
The actual input looks like this, it's an array of these smaller 10x10 arrays:
array([[ 2, -1, -1, -1, -1, -1, -1, -1, -1, 0],
[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[11, -1, 11, 6, 3, 2, -1, -1, -1, 11],
[-1, -1, -1, -1, 5, 7, -1, -1, 2, 7],
[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, -1, -1, -1, -1, -1, -1],
[-1, -1, -1, -1, 22, 25, -1, -1, -1, 22],
[22, -1, -1, -1, 26, 29, -1, -1, 26, 25],
[27, -1, -1, -1, -1, -1, -1, -1, -1, 23],
[31, 24, 31, -1, -1, -1, -1, -1, -1, 31]])
I've tried to understand this issue by looking on stack overflow and elsewhere, but I can't figure out the problem and those solutions don't work for me.
Here's the model as of now:
x_train, x_test, y_train, y_test = train_test_split(xving, ywing, test_size=0.2)
x_train = numpy.array(x_train)
y_train = numpy.array(y_train)
model = Sequential()
model.add(keras.layers.Dense(250,activation='tanh', input_shape=(None,10,10)))
model.add(keras.layers.Dense(150,activation='relu'))
model.add(keras.layers.Dense(25,activation='sigmoid'))
model.add(keras.layers.Dense(2,activation='softmax'))
optimizerr = keras.optimizers.SGD(lr=0.01, momentum=0.0, decay=0.0, nesterov=False)
model.compile(optimizer=optimizerr, loss='categorical_crossentropy', metrics=['accuracy'])
model.fit(x_train, y_train,epochs = 25, batch_size = 32, verbose=1)
EDIT: So when I use:
input_shape=x_train.shape[1:]
The error becomes with the target:
Error when checking target: expected dense_32 to have 3 dimensions, but got array with shape (1169909, 1)
But the target is an array. When I keep it as a list, I instead get the error:
ValueError: Error when checking model target: the list of Numpy arrays that you are passing to your model is not the size the model expected. Expected to see 1 array(s), but instead got the following list of 1169909 arrays: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0...
So now I guess my question concerns why the target is an issue.
y_train.shape
yields:
(1169909,)
So I'm confused still?