focal-loss: alpha parameter in binary classification
Opened this issue · 3 comments
"alpha: A scalar for focal loss alpha hyper-parameter. If positive samples number > negtive samples number, alpha < 0.5 and vice versa."
your function:
L=-labels*(1-alpha)*((1-y_pred)*gamma)*tf.log(y_pred)-\ (1-labels)*alpha*(y_pred**gamma)*tf.log(1-y_pred)
note: * and ** are same?
in original paper function:
L = -labels*alpha*((1-y_pred)^gamma)*tf.log(y_pred)-\ (1-labels)*(1-alpha)*(y_pred^gamma)*tf.log(1-y_pred)
so i think if positive samples number > negtive , alpha > 0.5 and vice versa.
However, in your ways, if positive > negtive, alpha < 0.5 and vice versa.
您好,请问运用focal-loss的时候您出现过这个问题吗?InvalidArgumentError (see above for traceback): tags and values not the same shape: [] != [256]
没遇到过 @lilmangolil , 你注意下公式里面tensor 如何做平方运算,最简单的就是直接相乘,或者用pow
@lilmangolil 这个是因为你有把返回的loss放进这个函数吧tf.summary.scalar
tf.summary.scalar要求输入为scalar,他的函数返回的loss是个tensor
你还需要reduce一下