          u_pred = K.mean(patches_pred, axis=-1)
          # Get variance
          var_true = K.var(patches_true, axis=-1)
          var_pred = K.var(patches_pred, axis=-1)
          # Get std dev
          covar_true_pred = K.mean(
              patches_true * patches_pred, axis=-1) - u_true * u_pred
  
          ssim = (2 * u_true * u_pred + self.c_1) * (
              2 * covar_true_pred + self.c_2)
 
</s> remove         ssim /= denom  # no need for clipping, c_1 + c_2 make the denom non-zero
 </s> add         ssim /= denom  # no need for clipping, c_1 + c_2 make the denorm non-zero </s> remove def l_p_norm(y_true, y_pred, p_norm=np.inf):
    """
    Calculate the L-p norm as a loss function,
    valid choics of p are [0,1,no.inf]
    """
    diff = y_true - y_pred
    loss = tf.norm(diff, ord=p_norm, axis=-1)
    return loss


 </s> add  </s> remove     return inner_loss
 </s> add     return _inner_loss </s> remove     def inner_loss(y_true, y_pred):
        # Branching because tensorflows broadcasting is wonky and
        # plaidmls concatenate is implemented ineficient.
 </s> add     def _inner_loss(y_true, y_pred):
        """ Apply the loss function to the masked area of the image.

         Parameters
        ----------
        y_true: tensor or variable
            The ground truth value
        y_pred: tensor or variable
            The predicted value

        Returns
        -------
        tensor
            The Loss value

        Notes
        -----
        Branching because TensorFlow's broadcasting is wonky and plaidML's concatenate is
        implemented inefficiently.
        """ </s> remove     def make_kernel(sigma):
 </s> add     def _make_kernel(sigma):
        """ Make the gaussian kernel. """
        # Get standard deviation
          u_pred = K.mean(patches_pred, axis=-1)
          # Get variance
          var_true = K.var(patches_true, axis=-1)
          var_pred = K.var(patches_pred, axis=-1)
        # Get standard deviation
          covar_true_pred = K.mean(
              patches_true * patches_pred, axis=-1) - u_true * u_pred
  
          ssim = (2 * u_true * u_pred + self.c_1) * (
              2 * covar_true_pred + self.c_2)
keep keep keep keep replace keep keep keep keep keep
 Simple backend unit tests (#1020)

* Add simple backend tests for lib.model
* Document lib.model
* Fix GMSD Loss for AMD
* Remove obsolete code from lib.model 
lib/model/losses.py