Focal Loss

Hi,
How to implement Focal Loss in KNIME? Thanks!

BR,
Reg

Hi @Reg_Jen,

what do you mean by focal loss?
You can define custom loss functions in the keras network learner node.

Cheers,

nemad

Today I stumbled across a focal loss implementation for Keras which can be included in our learner node via the custom loss panel:

def focal_loss(target, output, gamma=2):
    output /= K.sum(output, axis=-1, keepdims=True)
    eps = K.epsilon()
    output = K.clip(output, eps, 1. - eps)
    return -K.sum(K.pow(1. - output, gamma) * target * K.log(output),
                          axis=-1)

The code is taken from here: https://github.com/keras-team/keras/issues/6261

Best,

Adrian

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.