Я начинаю с нейронных сетей. Я построил модель и обучил ее в своем учебном наборе данных. Но когда я пытаюсь оценить модель, я получаю ошибку несоответствия размеров: ValueError: Error when checking target: expected dense_16 to have shape (3,) but got array with shape (1,)
. Что касается меня, я не могу понять, откуда в определении модели он возникает. Любая помощь приветствуется.
Определение модели:
![enter image description here](https://i.stack.imgur.com/fL2DR.png)
Обучение:
![enter image description here](https://i.stack.imgur.com/KMrU3.png)
Оценка (ошибка):
![enter image description here](https://i.stack.imgur.com/2xsVS.png)
Код:
# Building a model - build a simple feedforward neural network for this problem.
# Specify all the parameters we will be using in our network
input_num_units = (32, 32, 3)
hidden_num_units = 1000
output_num_units = 3
epochs = 10
batch_size = 128
from keras.models import Sequential
from keras.layers import Dense, Flatten, InputLayer
# Define the network/model
model = Sequential([
InputLayer(input_shape=input_num_units),
Flatten(),
Dense(units=hidden_num_units, activation='relu'),
Dense(units=output_num_units, activation='softmax'),
])
model.summary()
# Compile our network and let it train for a while, with cross validation
model.compile(optimizer='sgd', loss='categorical_crossentropy', metrics=['accuracy'])
model.fit(train_x, train_y, batch_size=batch_size,epochs=epochs,verbose=1, validation_split=0.2)
score = model.evaluate(test_x, test_y, verbose=0)
print('Test loss:', score[0])
print('Test accuracy:', score[1])