Skip to content

Commit 4d50fac

Browse files
committed
revert
1 parent 88e8be8 commit 4d50fac

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

python/paddle/nn/layer/norm.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1752,7 +1752,7 @@ class SpectralNorm(Layer):
17521752
17531753
Step 1:
17541754
Generate vector U in shape of [H], and V in shape of [W].
1755-
While H is the :attr:`axis` th dimension of the input weights,
1755+
While H is the :attr:`dim` th dimension of the input weights,
17561756
and W is the product result of remaining dimensions.
17571757
17581758
Step 2:
@@ -1779,9 +1779,9 @@ class SpectralNorm(Layer):
17791779
17801780
Parameters:
17811781
weight_shape(list or tuple): The shape of weight parameter.
1782-
axis(int, optional): The index of dimension which should be permuted to the first before reshaping Input(Weight) to 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. Default: 0.
1782+
dim(int, optional): The index of dimension which should be permuted to the first before reshaping Input(Weight) to 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. Default: 0.
17831783
power_iters(int, optional): The number of power iterations to calculate spectral norm. Default: 1.
1784-
epsilon(float, optional): The epsilon for numerical stability in calculating norms. Default: 1e-12.
1784+
eps(float, optional): The epsilon for numerical stability in calculating norms. Default: 1e-12.
17851785
name (str, optional): The default value is None. Normally there is no need for user to set this property. For more information, please refer to :ref:`api_guide_Name` .
17861786
dtype (str, optional): Data type, it can be "float32" or "float64". Default: "float32".
17871787
@@ -1794,7 +1794,7 @@ class SpectralNorm(Layer):
17941794
import paddle
17951795
x = paddle.rand((2,8,32,32))
17961796
1797-
spectral_norm = paddle.nn.SpectralNorm(x.shape, axis=1, power_iters=2)
1797+
spectral_norm = paddle.nn.SpectralNorm(x.shape, dim=1, power_iters=2)
17981798
spectral_norm_out = spectral_norm(x)
17991799
18001800
print(spectral_norm_out.shape) # [2, 8, 32, 32]
@@ -1804,25 +1804,25 @@ class SpectralNorm(Layer):
18041804
def __init__(
18051805
self,
18061806
weight_shape,
1807-
axis=0,
1807+
dim=0,
18081808
power_iters=1,
1809-
epsilon=1e-12,
1809+
eps=1e-12,
18101810
dtype='float32',
18111811
):
18121812
super().__init__()
18131813
self._power_iters = power_iters
1814-
self._epsilon = epsilon
1815-
self._dim = axis
1814+
self._epsilon = eps
1815+
self._dim = dim
18161816
self._dtype = dtype
18171817

18181818
self._weight_shape = list(weight_shape)
18191819
assert (
18201820
np.prod(self._weight_shape) > 0
18211821
), "Any dimension of `weight_shape` cannot be equal to 0."
1822-
assert axis < len(self._weight_shape), (
1823-
"The input `axis` should be less than the "
1824-
"length of `weight_shape`, but received axis="
1825-
"{}".format(axis)
1822+
assert dim < len(self._weight_shape), (
1823+
"The input `dim` should be less than the "
1824+
"length of `weight_shape`, but received dim="
1825+
"{}".format(dim)
18261826
)
18271827
h = self._weight_shape[self._dim]
18281828
w = np.prod(self._weight_shape) // h

0 commit comments

Comments
 (0)