Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
54bbbfa7
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
54bbbfa7
编写于
3月 02, 2019
作者:
D
dengkaipeng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix doc statement. test=develop
上级
c1a69e3e
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
11 addition
and
10 deletion
+11
-10
paddle/fluid/operators/spectral_norm_op.cc
paddle/fluid/operators/spectral_norm_op.cc
+6
-5
python/paddle/fluid/layers/nn.py
python/paddle/fluid/layers/nn.py
+5
-5
未找到文件。
paddle/fluid/operators/spectral_norm_op.cc
浏览文件 @
54bbbfa7
...
@@ -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"
,
"epsilo
b
for numerical stability in "
"epsilo
n
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 normaliz
e
value of weight of
This layer calculates the spectral normaliz
ation
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.
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
54bbbfa7
...
@@ -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 calculate
s 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 follow
ing
s.
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 remain
ing
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
scal
e weight values.
Calculate :math:`\sigma(\mathbf{W})` and
normaliz
e 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 spe
tral normalization.
Variable: A tensor variable of weight
parameters after spec
tral normalization.
Examples:
Examples:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录