'Computes loss.
Computes the loss function. Assumes target is in self.data and predictions
are in self.state.
Args:
get_deriv: If True, computes the derivative of the loss function w.r.t the
inputs to this layer and puts the result in self.deriv.'

def GetLoss(self, get_deriv=False, **kwargs):

    perf = deepnet_pb2.Metrics()
    perf.MergeFrom(self.proto.performance_stats)
    perf.count = self.batchsize
    if (self.loss_function == deepnet_pb2.Layer.SQUARED_LOSS):
        self.state.subtract(self.data, target=self.deriv)
        error = (self.deriv.euclid_norm() ** 2)
        perf.error = error
        if get_deriv:
            self.ComputeDeriv()
    else:
        raise Exception('Unknown    loss    function    for    tanh    units.')
    return perf
