本文介绍了Keras-历时相关的损失函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Keras框架,我想实现一个与历时有关的损失函数(即,每个时期的损失函数都不相同)
I'm working with the Keras framework and I would like to implement an epoch dependent loss function (i.e the loss function isn't the same at each epoch)
您将如何做?您能否添加示例,例如基于 keras VAE教程?
How would you do that ? Can you add an example, for instance based on the keras VAE tutorial ?
谢谢您的帮助
推荐答案
这可以通过重新编译网络来完成.保存的权重不会因重新编译而改变.所以本质上是这样的:
This can be accomplished by recompiling the network. The weights are saved not changed by the recompilation. So in essence something like this:
for epoch in range(nb_epoch):
loss_function = loss_for_epoch(epoch)
model.compile(optimizer, loss_function, metrics)
model.fit(X, y, nb_epoch=1)
这篇关于Keras-历时相关的损失函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!