on_end_epoch Callback Issue

5 views
Skip to first unread message

Sergio Vera Martínez

unread,
May 12, 2021, 8:28:38 PM5/12/21
to TensorFlow End Users - GETTING STARTED, TUTORIALS & HOW-TO'S
Hello everyone,

I have a DQN agent with a Sequential model defined. Before fitting it, I load the model (it's been previously saved with load_model method) to save it later using the save method - as far as I know these methods load and save respectively the whole model, not only the weights -. I have a callback with a method on_epoch_end so I can calculate the mean accuracy of all my outputs. The problem is that, every time I fit the model (with 1 epoch by default), the log obtained calling on_epoch_end method accumulates. Next, this is how log looks like after two fittings (you can see how the name of the output is written twice). If I fit N times, it will appear N times as well.

{'loss': 3026263040.0, 'Output1_loss': 30916152.0, 'Output10_loss': 7287761.5, 'Output11_loss': 154010800.0, 'Output12_loss': 15293810.0, 'Output13_loss': 73967696.0, 'Output14_loss': 91059952.0, 'Output15_loss': 977938.5625, 'Output16_loss': 77277872.0, 'Output2_loss': 173771440.0, 'Output3_loss': 3320105.75, 'Output4_loss': 40071476.0, 'Output5_loss': 1127167488.0, 'Output6_loss': 565928448.0, 'Output7_loss': 211388864.0, 'Output8_loss': 361550272.0, 'Output9_loss': 92273024.0, 'Output1_Output1_accuracy': 1.0, 'Output10_Output10_accuracy': 1.0, 'Output11_Output11_accuracy': 1.0, 'Output12_Output12_accuracy': 1.0, 'Output13_Output13_accuracy': 1.0, 'Output14_Output14_accuracy': 0.5, 'Output15_Output15_accuracy': 1.0, 'Output16_Output16_accuracy': 0.5, 'Output2_Output2_accuracy': 0.5, 'Output3_Output3_accuracy': 0.5, 'Output4_Output4_accuracy': 0.5, 'Output5_Output5_accuracy': 0.5, 'Output6_Output6_accuracy': 0.5, 'Output7_Output7_accuracy': 1.0, 'Output8_Output8_accuracy': 1.0, 'Output9_Output9_accuracy': 1.0} 

Does anybody know how to solve this? For now, I only check if the key contains the word '"accuracy" but I don't believe it's a good practice. Thanks in advance.

Best regards
Reply all
Reply to author
Forward
0 new messages