Answer the question
In order to leave comments, you need to log in
Why can't NumPy specify the correct size?
In the network, the input layer must have 4 neurons. The input must be 1 list, the length of which is 4, each element is a number.
Here is the first layer:
self.model.add(layers.Dense(4, activation = "sigmoid", input_shape=(4, )))
print("SHAPE:", np.array([1, 1, 1, 1]).shape)
self.model.fit(np.array([1, 1, 1, 1]),
self.rightAnswer,
epochs = 1,
batch_size = 1)
SHAPE: (4,)
ValueError: Error when checking input: expected dense_1_input to have shape (4,) but got array with shape (1,)
Answer the question
In order to leave comments, you need to log in
Because I didn't read the documentation
# as first layer in a sequential model: model = Sequential() model.add(Dense(32, input_shape=(16,))) # now the model will take as input arrays of shape (*, 16) # and output arrays of shape (*, 32) # after the first layer, you don't need to specify # the size of the input anymore: model.add(Dense(32))
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question