Zero loss when output has no error.

Mask loss and loss gradient based on output matching the input.