Discount parameter in the loss layer

12 views
Skip to first unread message

Corey Nolet

unread,
Jan 23, 2017, 12:10:11 PM1/23/17
to Keras-users
I have a custom loss layer that discounts the loss for a specific class (because of class imbalance) and decreases the discount over the entire training period (until, eventually, there is no discount at all).

How would I decrement this value from epoch to epoch? I'm specifying my loss function like this:

def fcrn_loss(y_true, y_pred):
  ....



Thanks!

Klemen Grm

unread,
Jan 24, 2017, 8:42:59 AM1/24/17
to Keras-users, cjn...@gmail.com
You could do it with a global keras variable that you change at the end of every training epoch, eg. with a custom callback.

Corey Nolet

unread,
Jan 24, 2017, 10:49:02 AM1/24/17
to Klemen Grm, Keras-users
I tried your solution with a Theano shared variable that I update in a custom callback and it looks like it's working. Thanks!
Reply all
Reply to author
Forward
0 new messages