def GetLoss(self, get_deriv=False, **kwargs):
    perf = deepnet_pb2.Metrics()
    perf.MergeFrom(self.proto.performance_stats)
    perf.count = self.batchsize
    tiny = self.tiny
    if self.loss_function == deepnet_pb2.Layer.SQUARED_LOSS:
      if get_deriv:
        target = self.deriv
      else:
        target = self.statesize
      if 'precision' in self.params:
        self.data.mult_by_col(self.params['precision'], target=target)
        target.subtract(self.state)
      else:
        self.state.subtract(self.data, target=target)
      error = target.euclid_norm()**2
      perf.error = error
      if get_deriv:
        self.ComputeDeriv()
    elif self.loss_function == deepnet_pb2.Layer.HINGE_LOSS:
      pass
    else:
      raise Exception('Unknown loss function for linear units.')
    return perf
Compute loss and also deriv w.r.t to it if asked for.
dataset/ETHPy150Open nitishsrivastava/deepnet/deepnet/linear_layer.py/LinearLayer.GetLoss