我正在尝试构建神经网络并在下面执行此操作:
from keras.layers import Dense, Activation
model.add(Dense(units=64))
model.add(Activation('relu'))
model.add(Dense(units=10))
model.add(Activation('softmax'))
model.compile(loss='categorical_crossentropy',
optimizer='sgd',
metrics=['accuracy'])
我将x_train和y_train指定为numpy数组:
x_train=np.asarray(X_train)
y_train=np.asarray(y_train)
x_train.shape #(261, 8)
y_train.shape #(261,)
model.compile(optimizer='rmsprop',
loss='categorical_crossentropy',
metrics=['accuracy'])
model.fit(x_train, y_train, epochs=5, batch_size=32)
在输出时我有一个错误:
ValueError: Error when checking input: expected dense_1_input to have shape (None, 100) but got array with shape (261, 8)
我做错了什么?