Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
dbb8d078
P
Paddle
项目概览
PaddlePaddle
/
Paddle
12 个月 前同步成功
通知
2292
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dbb8d078
编写于
3月 02, 2019
作者:
D
dengkaipeng
提交者:
ceci3
3月 06, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix doc statement. test=develop
上级
eeeebdd0
变更
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
浏览文件 @
dbb8d078
...
...
@@ -101,9 +101,10 @@ class SpectralNormOpMaker : public framework::OpProtoAndCheckerMaker {
"This tensor is in same shape with Input(Weight)."
);
AddAttr
<
int
>
(
"dim"
,
"dimension corresponding to number of outputs, "
"it should be set as 0 if Input(Weight) is the "
"weight of fc layer, and should be set as 1 if "
"The index of dimention which should be permute "
"to the first before reshape 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."
)
.
SetDefault
(
0
);
...
...
@@ -112,12 +113,12 @@ class SpectralNormOpMaker : public framework::OpProtoAndCheckerMaker {
"spectral norm, default 1."
)
.
SetDefault
(
1
);
AddAttr
<
float
>
(
"eps"
,
"epsilo
b
for numerical stability in "
"epsilo
n
for numerical stability in "
"calculating norms"
)
.
SetDefault
(
1e-12
);
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
tensor.
...
...
python/paddle/fluid/layers/nn.py
浏览文件 @
dbb8d078
...
...
@@ -3353,14 +3353,14 @@ def spectral_norm(weight, dim=0, power_iters=1, eps=1e-12, name=None):
"""
**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
Parameters. Calculations are showed as follow
ing
s.
Parameters. Calculations are showed as follows.
Step 1:
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,
and W is the product result of remain dimensions.
and W is the product result of remain
ing
dimensions.
Step 2:
:attr:`power_iters` shoule be a positive interger, do following
...
...
@@ -3373,7 +3373,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}
Step 3:
Calculate :math:`\sigma(\mathbf{W})` and
scal
e weight values.
Calculate :math:`\sigma(\mathbf{W})` and
normaliz
e weight values.
.. math::
...
...
@@ -3392,7 +3392,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.
Returns:
Variable: A tensor variable of weight
after spe
tral normalization.
Variable: A tensor variable of weight
parameters after spec
tral normalization.
Examples:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录