【发布时间】:2020-05-30 06:12:45
【问题描述】:
我的学习模型如下(使用 Keras)。
model = Sequential()
model.add(Dense(100, activation='relu', input_shape = (X_train.shape[0],)))
model.add(Dense(500, activation='relu'))
model.add(Dense(2, activation='softmax'))
我的输入数据 X_train 是一个形状为 (180,) 的数组,对应的包含标签的 y_train 也是一个形状为 (180,) 的数组。我尝试编译和拟合模型如下。
model.compile(loss="sparse_categorical_crossentropy",
optimizer="adam",
metrics=['accuracy'])
model.fit(X_train, y_train, epochs = 200)
运行model.fit()时遇到如下错误:
ValueError: Error when checking input: expected dense_1_input to have
shape (180,) but got array with shape (1,)
我不确定自己做错了什么,因为我对深度学习还很陌生。任何帮助表示赞赏。谢谢。
【问题讨论】:
-
X_train的大小是多少 -
@ShubhamShaswat 180
标签: python tensorflow keras deep-learning