sbaur
sbaur

Reputation: 303

Keras - epoch dependant loss function

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)

How would you do that ? Can you add an example, for instance based on the keras VAE tutorial ?

Thank you for your help

Upvotes: 3

Views: 3369

Answers (1)

Thomas Pinetz
Thomas Pinetz

Reputation: 7148

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)

Upvotes: 3

Related Questions