VAE 的测试步骤仅返回 0s

问题描述 投票:0回答:1

我正在跳回一个去年(大部分)停止工作的项目。我已经遇到过这个问题,并且这个答案当时解决了它。我目前正在运行基本上与该答案完全相同的脚本,但现在在训练期间,我又回到了验证损失全 0,无论是 KL 还是重建。

history = var_autoencoder.fit( x_train, x_train, epochs=1000, shuffle=True, validation_data=(x_test, x_test), 
                 callbacks=kcb.EarlyStopping(monitor="val_loss", patience=30, restore_best_weights=True) )

Epoch 1/1000
107/107 [==============================] - 3s 30ms/step - loss: 118.1165 - reconstruction_loss: 117.0647 - kl_loss: 1.0518 - val_loss: 0.0000e+00 - val_reconstruction_loss: 0.0000e+00 - val_kl_loss: 0.0000e+00
Epoch 2/1000
107/107 [==============================] - 3s 30ms/step - loss: 104.4190 - reconstruction_loss: 103.7018 - kl_loss: 0.7172 - val_loss: 0.0000e+00 - val_reconstruction_loss: 0.0000e+00 - val_kl_loss: 0.0000e+00
Epoch 3/1000
107/107 [==============================] - 3s 30ms/step - loss: 103.2905 - reconstruction_loss: 102.5077 - kl_loss: 0.7828 - val_loss: 0.0000e+00 - val_reconstruction_loss: 0.0000e+00 - val_kl_loss: 0.0000e+00
Epoch 4/1000
107/107 [==============================] - 3s 31ms/step - loss: 101.7333 - reconstruction_loss: 100.8803 - kl_loss: 0.8530 - val_loss: 0.0000e+00 - val_reconstruction_loss: 0.0000e+00 - val_kl_loss: 0.0000e+00

可以在此处

找到示例数据集和完整脚本
tensorflow keras autoencoder
1个回答
0
投票

在此示例中,他们还从 Tensorflow 页面更新了

test_step
函数中的指标:

# Update the metrics.
for metric in self.metrics:
    if metric.name != "loss":
        metric.update_state(y, y_pred)

如果不进行更新,评估指标将保持其初始值零。

© www.soinside.com 2019 - 2024. All rights reserved.