loss function with mean or sum,which is better?
Hello, Brother! In your code categorical_crossentropy compute with mean, https://github.com/qubvel/segmentation_models/blob/e9cac0d5bc2a7c0e1c6fa9050d988a6f9854313c/segmentation_models/base/functional.py#L251 but in keras code ,the return is
return - tf.reduce_sum(target * tf.log(output), axis)
https://github.com/keras-team/keras/blob/c10d24959b0ad615a21e671b180a1b2466d77a2b/keras/backend/tensorflow_backend.py#L3564
so which is better?
There are no difference, keras average them anyway (because K.categorical_crossentropy does not return scalar)
@qubvel This is a great library and we are using it extensively these days. Thanks. I also stumbled upon this exact same question asked here. Why do you think there are no difference between your implementation and keras? If I understand correctly in keras they do not count the number of classes in their mean calculation but in our case we do it. Though it should not affect the training, still what we calculate here is a scaled version of cross entrophy and the scaling depends on the number of classes. isn't it?