Keras - 纪元相关损失函数 [英] Keras - epoch dependant loss function

查看:30
本文介绍了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 - 纪元相关损失函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆