Search code examples
kerasneural-networkkeras-layer

How to print weights and bias during training after each epoch


How to print the weights and bias in a neural network after each epoch during training

I have tried the following code:

print_weights = LambdaCallback(on_epoch_end=lambda epoch, logs: print(merged.layers[1].get_weights()[0][0:5], merged.layers[2].get_weights()[0][0:5]))


merged.compile(optimizer='adam',loss=[loss1, loss2],loss_weights=[alpham, 1 - alpham], metrics=['accuracy'],callbacks = [print_weights])  

But I am getting the following error:

ValueError: ('Some keys in session_kwargs are not supported at this time: %s', dict_keys(['callbacks']))


Solution

  • model.compile does not take the callbacks, that is given to model.fit.