loss function

Computes Loss Function.