class_docstr: Discriminative margin-based clustering loss function
  
  This is the implementation of the following paper:
  https://arxiv.org/abs/1708.02551
  This method is a semi-supervised solution to instance segmentation.
  It calculates pixel embeddings, and calculates three different terms
  based on those embeddings and applies them as loss.
  The main idea is that the pixel embeddings
  for same instances have to be closer to each other (pull force),
  for different instances, they have to be further away (push force).
  The loss also brings a weak regularization term to prevent overfitting.
  This loss function calculates the following three parameters:
  
  Variance Loss
      Loss to penalize distances between pixels which are belonging
      to the same instance. (Pull force)
  
  Distance loss
      Loss to penalize distances between the centers of instances.
      (Push force)
  
  Regularization loss
      Small regularization loss to penalize weights against overfitting.
class_docstr_tok: ["Discriminative","margin-based","clustering","loss","function","This","is","the","implementation","of","the","following","paper",":","https",":","\/\/arxiv.org\/abs\/1708.02551","This","method","is","a","semi-supervised","solution","to","instance","segmentation",".","It","calculates","pixel","embeddings",",","and","calculates","three","different","terms","based","on","those","embeddings","and","applies","them","as","loss",".","The","main","idea","is","that","the","pixel","embeddings","for","same","instances","have","to","be","closer","to","each","other","(","pull","force",")",",","for","different","instances",",","they","have","to","be","further","away","(","push","force",")",".","The","loss","also","brings","a","weak","regularization","term","to","prevent","overfitting",".","This","loss","function","calculates","the","following","three","parameters",":","Variance","Loss","Loss","to","penalize","distances","between","pixels","which","are","belonging","to","the","same","instance",".","(","Pull","force",")","Distance","loss","Loss","to","penalize","distances","between","the","centers","of","instances",".","(","Push","force",")","Regularization","loss","Small","regularization","loss","to","penalize","weights","against","overfitting","."]
code: def __init__(
      self,
      delta_v=0.5,
      delta_d=1.5,
      max_embedding_dim=10,
      norm=1,
      alpha=1.0,
      beta=1.0,
      gamma=0.001,
  ):
      self.delta_v = delta_v
      self.delta_d = delta_d
      self.alpha = alpha
      self.beta = beta
      self.gamma = gamma
      self.max_embedding_dim = max_embedding_dim
  
      if self.max_embedding_dim <= 0:
          raise ValueError(
              "Max number of embeddings has to be positive!"
          )
  
      # L1 or L2 norm is allowed only
      if norm == 1:
          self.norm = lambda x, axis=None: c_sum(absolute(x), axis=axis)
      elif norm == 2:
          self.norm = lambda x, axis=None: sqrt(
              c_sum(x**2, axis=axis)
          )
      else:
          raise ValueError(
              "For discriminative loss, "
              "norm can only be 1 or 2. "
              "Obtained the value : {}".format(norm)
          )
  
file_path: chainer/chainer/functions/loss/discriminative_loss.py
imports: from chainer import backend
  from chainer.functions.activation.relu import relu
  from chainer.functions.array.broadcast import broadcast_to
  from chainer.functions.math.basic_math import absolute
  from chainer.functions.math.sqrt import sqrt
  from chainer.functions.math.sum import sum
label_desc: Use image node_id 1 to create a new DiscriminativeMarginBasedClusteringLoss object from inherited base classes: object with example: obj = DiscriminativeMarginBasedClusteringLoss(delta_v, delta_d, max_embedding_dim, norm, alpha, beta, gamma)