umbertogriffo / focal-loss-keras

Binary and Categorical Focal loss implementation in Keras.
278 stars 67 forks source link

different batchsize different loss value #5

Closed AFOXCOW closed 4 years ago

AFOXCOW commented 5 years ago

the keras custom loss function input shape require (batchsize,outputshape) or (outputshape,batchsize), but your code is calculate the loss of one output picture. thus leading the loss value vary from the batchsize. the first is calculated with batchsize=1 the second is calculated with batchsize=10 a

decewei commented 5 years ago

simple fix: K.mean instead of K.sum

AFOXCOW commented 5 years ago

Thanks a lot. Thats what I have done. But can you update the code for future readers. Thanks again.

Raazzta commented 4 years ago

hi @AFOXCOW , @celinew1221 , in which line should we fix it?

decewei commented 4 years ago

hi @AFOXCOW , @celinew1221 , in which line should we fix it?

I submitted a pull request regarding this.

umbertogriffo commented 4 years ago

Many Thanks @celinew1221 Let's merge.