如何在每个纪元后的训练中打印权重和偏差

How to print weights and bias during training after each epoch

如何在训练期间的每个时期后打印神经网络中的权重和偏差

我试过以下代码:

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])  

但我收到以下错误:

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

model.compile 不接受回调,即给 model.fit.