You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by gi...@git.apache.org on 2017/09/05 19:26:11 UTC

[GitHub] szha commented on a change in pull request #7570: Gluon InstanceNorm and ReflectancePadding

szha commented on a change in pull request #7570: Gluon InstanceNorm and ReflectancePadding
URL: https://github.com/apache/incubator-mxnet/pull/7570#discussion_r137090552
 
 

 ##########
 File path: python/mxnet/gluon/nn/basic_layers.py
 ##########
 @@ -442,3 +442,87 @@ def hybrid_forward(self, F, x):
 
     def __repr__(self):
         return self.__class__.__name__
+
+
+class InstanceNorm(HybridBlock):
+    """
+    Applies instance normalization to the n-dimensional input array.
+    This operator takes an n-dimensional input array where (n>2) and normalizes 
+    the input using the following formula:
+    .. math::
+    out = \frac{x - mean[data]}{ \sqrt{Var[data]} + \epsilon} * gamma + beta
+    This layer is similar to batch normalization layer (`BatchNorm`)
+    with two differences: first, the normalization is
+    carried out per example (instance), not over a batch. Second, the
+    same normalization is applied both at test and train time. This
+    operation is also known as `contrast normalization`.
+    If the input data is of shape [batch, channel, spacial_dim1, spacial_dim2, ...],
+    `gamma` and `beta` parameters must be vectors of shape [channel].
+    This implementation is based on paper:
+    .. [1] Instance Normalization: The Missing Ingredient for Fast Stylization,
+       D. Ulyanov, A. Vedaldi, V. Lempitsky, 2016 (arXiv:1607.08022v2).
+    Examples::
+      // Input of shape (2,1,2)
 
 Review comment:
   add an empty line after ::
   http://www.sphinx-doc.org/en/stable/rest.html#source-code
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services