juglab / n2v

This is the implementation of Noise2Void training.
Other
387 stars 107 forks source link

Question about loss function #101

Closed jonathanventura closed 3 years ago

jonathanventura commented 3 years ago

Why is the loss function

    loss = tf.reduce_sum(K.square(target - y_pred*mask)) / tf.reduce_sum(mask)

instead of

    loss = tf.reduce_sum(K.square(target - y_pred)*mask) / tf.reduce_sum(mask)

?

tibuch commented 3 years ago

Hi @jonathanventura

We initialize target with zeros and only set values at the active pixels. So target - y_pred*mask is zero everywhere except at the active pixels.

Your suggested loss should lead to the same result and looks like the safer choice to be honest :)

jonathanventura commented 3 years ago

Ah, that makes sense -- thank you!