【问题标题】:Error when checking target: Expected output to have shape (None, 4) but got array with shape (30,3)检查目标时出错:预期输出具有形状 (None, 4) 但得到的数组具有形状 (30,3)
【发布时间】:2020-04-24 23:17:45
【问题描述】:

我正致力于在 Keras 中训练一个类似 VGG16 的模型。我正在使用 TAM 数据集并收到此错误。 我阅读了多个类似的问题,但到目前为止没有一个对我有帮助。

这是代码

for layer in model.layers:
    layer.trainable = True

model.compile(optimizer=optimizers.SGD(lr=0.0001, momentum=0.9),
              loss='categorical_crossentropy', metrics = ['accuracy'])

checkpoint = ModelCheckpoint(filepath=model_weights, save_best_only=False, verbose=0)
reduce_lr = ReduceLROnPlateau(monitor='loss', factor=0.2, patience=10, min_lr=0.00001)

history = model.fit_generator(
            generator=train_batches,
            steps_per_epoch=10,
            epochs=5,
            callbacks=[checkpoint, reduce_lr],
            validation_data=valid_batches,
            validation_steps=100,
            verbose=1
)

【问题讨论】:

    标签: python image keras medical


    【解决方案1】:

    您的生成器(或您的模型)似乎是错误的。您的模型需要一种形状并得到另一种形状。请发布您的完整代码或更多详细信息,我们可以为您提供帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-13
      • 1970-01-01
      • 2018-09-18
      • 2018-03-12
      • 2017-07-03
      • 2018-01-01
      相关资源
      最近更新 更多