我又开始着手去年(大部分)停止的一个项目。我已经遇到过这个问题,当时这个答案解决了它。我目前正在运行基本上与该答案完全相同的脚本,但现在在训练过程中,我得到的验证损失(包括 KL 和重建)又全部为 0。
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 页面的这个例子中,他们还更新了函数中的指标
test_step
:如果没有更新,评估指标将保持其初始化值零。