提交 54bbbfa7 编写于 作者: D dengkaipeng

fix doc statement. test=develop

上级 c1a69e3e
...@@ -101,9 +101,10 @@ class SpectralNormOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -101,9 +101,10 @@ class SpectralNormOpMaker : public framework::OpProtoAndCheckerMaker {
"This tensor is in same shape with Input(Weight)."); "This tensor is in same shape with Input(Weight).");
AddAttr<int>("dim", AddAttr<int>("dim",
"dimension corresponding to number of outputs, " "The index of dimention which should be permute "
"it should be set as 0 if Input(Weight) is the " "to the first before reshape Input(Weight) to "
"weight of fc layer, and should be set as 1 if " "matrix, it should be set as 0 if Input(Weight) is "
"the weight of fc layer, and should be set as 1 if "
"Input(Weight) is the weight of conv layer, " "Input(Weight) is the weight of conv layer, "
"default 0.") "default 0.")
.SetDefault(0); .SetDefault(0);
...@@ -112,12 +113,12 @@ class SpectralNormOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -112,12 +113,12 @@ class SpectralNormOpMaker : public framework::OpProtoAndCheckerMaker {
"spectral norm, default 1.") "spectral norm, default 1.")
.SetDefault(1); .SetDefault(1);
AddAttr<float>("eps", AddAttr<float>("eps",
"epsilob for numerical stability in " "epsilon for numerical stability in "
"calculating norms") "calculating norms")
.SetDefault(1e-12); .SetDefault(1e-12);
AddComment(R"DOC( AddComment(R"DOC(
This layer calculates the spectral normalize value of weight of This layer calculates the spectral normalization value of weight of
fc, conv1d, conv2d, conv3d layers which should be 2-D, 3-D, 4-D, 5-D fc, conv1d, conv2d, conv3d layers which should be 2-D, 3-D, 4-D, 5-D
tensor. tensor.
......
...@@ -3352,14 +3352,14 @@ def spectral_norm(weight, dim=0, power_iters=1, eps=1e-12, name=None): ...@@ -3352,14 +3352,14 @@ def spectral_norm(weight, dim=0, power_iters=1, eps=1e-12, name=None):
""" """
**Spectral Normalization Layer** **Spectral Normalization Layer**
This layer calculate the spectral normalize value of weight parameters of This layer calculates the spectral normalization value of weight parameters of
fc, conv1d, conv2d, conv3d layers which should be 2-D, 3-D, 4-D, 5-D fc, conv1d, conv2d, conv3d layers which should be 2-D, 3-D, 4-D, 5-D
Parameters. Calculations are showed as followings. Parameters. Calculations are showed as follows.
Step 1: Step 1:
Generate vector U in shape of [H], and V in shape of [W]. Generate vector U in shape of [H], and V in shape of [W].
While H is the :attr:`dim` th dimension of the input weights, While H is the :attr:`dim` th dimension of the input weights,
and W is the product result of remain dimensions. and W is the product result of remaining dimensions.
Step 2: Step 2:
:attr:`power_iters` shoule be a positive interger, do following :attr:`power_iters` shoule be a positive interger, do following
...@@ -3372,7 +3372,7 @@ def spectral_norm(weight, dim=0, power_iters=1, eps=1e-12, name=None): ...@@ -3372,7 +3372,7 @@ def spectral_norm(weight, dim=0, power_iters=1, eps=1e-12, name=None):
\mathbf{u} := \\frac{\mathbf{W}^{T} \mathbf{v}}{\|\mathbf{W}^{T} \mathbf{v}\|_2} \mathbf{u} := \\frac{\mathbf{W}^{T} \mathbf{v}}{\|\mathbf{W}^{T} \mathbf{v}\|_2}
Step 3: Step 3:
Calculate :math:`\sigma(\mathbf{W})` and scale weight values. Calculate :math:`\sigma(\mathbf{W})` and normalize weight values.
.. math:: .. math::
...@@ -3391,7 +3391,7 @@ def spectral_norm(weight, dim=0, power_iters=1, eps=1e-12, name=None): ...@@ -3391,7 +3391,7 @@ def spectral_norm(weight, dim=0, power_iters=1, eps=1e-12, name=None):
name (str): The name of this layer. It is optional. name (str): The name of this layer. It is optional.
Returns: Returns:
Variable: A tensor variable of weight after spetral normalization. Variable: A tensor variable of weight parameters after spectral normalization.
Examples: Examples:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册