【问题标题】:training loss and validation loss both become 0.00000e+00 always训练损失和验证损失总是变成 0.00000e+00
【发布时间】:2020-12-23 14:24:46
【问题描述】:

有人可以帮我解决这个问题,为什么我的损失为 0.0000e+00。

我环顾四周发现很少有人遇到同样的问题,但我无法按照相同的建议解决它。

行被打乱,标签已经转换为 float32。这些是我在类似问题上找到的建议。你能告诉我我哪里错了吗?

这个问题是类别超过 1 的图像的分类。

这就是我创建模型的方式


def createmodel():
    pretrained = InceptionV3(input_shape=(150,150,3),
                        include_top=False,
                        weights='imagenet')
    for layer in pretrained.layers:
        layer.trainable = False  


    x = layers.Flatten()(pretrained.output)
    x = layers.Dense(1024,activation='relu')(x) 
    x = layers.Dropout(0.2)(x)
    x = layers.Dense(1,activation="softmax")(x)
    model = Model(pretrained.input,x)
    model.compile(optimizer = Adam(0.001),
                  loss = 'categorical_crossentropy',
                  )
    return model
Epoch 1/2
10/10 [==============================] - 3s 322ms/step - loss: 0.0000e+00 - val_loss: 0.0000e+00
Epoch 2/2
10/10 [==============================] - 5s 464ms/step - loss: 0.0000e+00 - val_loss: 0.0000e+00

【问题讨论】:

    标签: machine-learning image-processing neural-network conv-neural-network


    【解决方案1】:

    最后一层有问题。大小应该等于类的数量而不是 1,即:

    x = layers.Dense(num_classes, activation="softmax")(x)
    

    假设 num_classes 是您数据中不同类的数量。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-11-29
      • 1970-01-01
      • 2019-04-02
      • 1970-01-01
      • 2018-04-05
      • 1970-01-01
      • 1970-01-01
      • 2020-09-04
      相关资源
      最近更新 更多