【发布时间】:2020-05-10 07:43:18
【问题描述】:
我正在尝试使用我的模型进行预测,其中数组的形状为 (3084, 32, 32)。 获取值错误 here is error image
这是我的模型
model.add(Dense(1028, input_shape = (3084,), activation = "sigmoid"))
model.add(Dense(514, activation="sigmoid"))
model.add(Dense(len(lb.classes_), activation="softmax"))
总结
Model: "sequential_21"
_________________________________________________________________
Layer (type) Output Shape Param #
=================================================================
dense_57 (Dense) (None, 1028) 3171380
_________________________________________________________________
dense_58 (Dense) (None, 514) 528906
_________________________________________________________________
dense_59 (Dense) (None, 4) 2060
=================================================================
Total params: 3,702,346
Trainable params: 3,702,346
Non-trainable params: 0
_________________________________________________________________
尝试使用
opt = SGD(lr = 0.01)
model.compile(loss = "categorical_crossentropy", optimizer=opt, metrics=["accuracy"])
H = model.fit(train_X, train_Y, validation_data = (test_X, test_Y), epochs = 75, batch_size = 32)
【问题讨论】:
-
为什么你的输入形状是 3084 却传递了 32,32 个数据?
-
据我了解,我正在传递 3084,这是要训练的图像数量。 32,32 是图像大小。
-
这是我的完整代码:colab.research.google.com/drive/…
标签: python-3.x tensorflow keras artificial-intelligence