我正在使用keras和Tensorflow进行电影评论的分数预测。我正在尝试在出现此错误的地方训练模型。我究竟做错了什么?我已经附上了示例代码。
模型构建:
model = Sequential()
model.add(Dense(512, input_shape=(vocab_size,)))
model.add(Activation('relu'))
model.add(Dropout(0.3))
model.add(Dense(512))
model.add(Activation('relu'))
model.add(Dropout(0.3))
model.add(Dense(20))
model.add(Activation('softmax'))
model.summary()
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
To Train the Model:
num_epochs =10
batch_size = 128
history = model.fit(X_train, y_train, batch_size=batch_size, epochs=num_epochs, verbose=2,
validation_split=0.2)