      Code borrows from https://github.com/flyyufelix/cnn_finetune
      """
      def __init__(self, weights=None, axis=-1, gamma_init='zero', **kwargs):
          self.axis = axis
          self.gamma_init = initializers.get(gamma_init)
          self.initial_weights = weights
          super(Scale, self).__init__(**kwargs)
  
      def build(self, input_shape):
          self.input_spec = [InputSpec(shape=input_shape)]
 
</s> remove         kernel_width, kernel_height  = self.kernel_size, self.kernel_size
 </s> add         kernel_width, kernel_height = self.kernel_size, self.kernel_size </s> remove def perceptual_loss(real, fake_abgr, distorted, mask_eyes, vggface_feats, **weights):
 </s> add def perceptual_loss(real, fake_abgr, distorted, vggface_feats, **weights): </s> remove         radius = max(1, round(mask_diameter * radius_ratio / 100))
        kernel_size = int((radius * 2) + 1)
 </s> add         radius = round(max(1., mask_diameter * radius_ratio / 100.))
        kernel_size = radius * 2 + 1 </s> remove def staircase_loss(y_true, y_pred, var_a=16.0, cnst=1.0/255.0):
    """ Keras Staircase Loss """
    height = cnst
    width = cnst
    var_x = K.clip(K.abs(y_true - y_pred) - 0.5 * cnst, 0.0, 1.0)
    loss = height*(K.tanh(var_a*((var_x/width)-tf.floor(var_x/width)-0.5)) /
                   (2.0*K.tanh(var_a/2.0)) + 0.5 + tf.floor(var_x/width))
    loss += 1e-10
    return K.mean(loss, axis=-1)
 </s> add 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


def l_inf_norm(y_true, y_pred):
    """ Calculate the L-inf norm as a loss function """
    diff = K.abs(y_true - y_pred)
    max_loss = K.max(diff, axis=(1, 2), keepdims=True)
    loss = K.mean(max_loss, axis=-1)
    return loss </s> remove             def reducer(var_x, kernel):
                shape = tf.shape(var_x)
                var_x = tf.reshape(var_x, shape=tf.concat([[-1], shape[-3:]], 0))
                var_y = tf.nn.depthwise_conv2d(var_x, kernel, strides=[1, 1, 1, 1], padding='VALID')
                return tf.reshape(var_y, tf.concat([shape[:-3], tf.shape(var_y)[1:]], 0))
 </s> add             def reducer(img1, kernel):
                shape = tf.shape(img1)
                img1 = tf.reshape(img1, shape=tf.concat([[-1], shape[-3:]], 0))
                img2 = tf.nn.depthwise_conv2d(img1, kernel, strides=[1, 1, 1, 1], padding='VALID')
                return tf.reshape(img2, tf.concat([shape[:-3], tf.shape(img2)[1:]], 0))
        self.gamma = None
      Code borrows from https://github.com/flyyufelix/cnn_finetune
      """
      def __init__(self, weights=None, axis=-1, gamma_init='zero', **kwargs):
          self.axis = axis
        self.gamma = None
          self.gamma_init = initializers.get(gamma_init)
          self.initial_weights = weights
          super(Scale, self).__init__(**kwargs)
  
      def build(self, input_shape):
          self.input_spec = [InputSpec(shape=input_shape)]
keep keep keep add keep keep keep keep keep keep
 documentation, pep8, style, clarity updates  - Prep for Segmentation (#812)

* documentation, pep8, style, clarity updates

* Update cli.py

* Update _config.py

remove extra mask and coverage

mask type as dropdown

* Update training_data.py

move coverage / LR to global
cut down on loss description

style change
losses working in PR

* simpler logging

* legacy update 
lib/model/layers.py