我正在尝试使用输入暗淡 2499 训练模型
layers = [2499, 689, 363, 192]
activation = ["relu", "relu", "sigmoid"]
# let's build our model
model = tf.keras.Sequential()
# we add the first layer and the input layer to our network
model.add(Dense(layers[1], input_shape=(layers[0],), activation=actv[0]))
# we add the hidden layers
for (x, i) in enumerate(layers):
if x > 1 and x != (len(layers) - 1):
model.add(Dense(i, activation=actv[x]))
# then add the final layer
model.add(Dense(layers[-1], activation=actv[-1]))
当我输入 (72,2499) 时,会出现错误:
ValueError: Input 0 of layer sequential is incompatible with the layer: expected axis -1 of input shape to have value 2499 but received input with shape (None, 28)
我不明白为什么会出现此错误,因为数组的最后一个维度 (72,2499) 与输入形状 2499 相同?
答案 0 :(得分:0)
来自评论
<块引用>向模型提供正确的数据(即 trainX)后问题得到解决 按预期工作(转述自 Bigyan Subedi)