Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
8aeac782
P
Paddle
项目概览
PaddlePaddle
/
Paddle
1 年多 前同步成功
通知
2302
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看板
提交
8aeac782
编写于
8月 06, 2018
作者:
Q
qiaolongfei
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
revert initializer.py
上级
aa546389
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
0 addition
and
47 deletion
+0
-47
python/paddle/fluid/initializer.py
python/paddle/fluid/initializer.py
+0
-47
未找到文件。
python/paddle/fluid/initializer.py
浏览文件 @
8aeac782
...
@@ -62,24 +62,6 @@ def init_on_cpu():
...
@@ -62,24 +62,6 @@ def init_on_cpu():
_force_init_on_cpu_
=
pre_state
_force_init_on_cpu_
=
pre_state
def
_is_inited_by
(
block
,
var
,
init_op_types
):
for
op
in
block
.
ops
:
if
var
.
name
in
op
.
output_arg_names
and
op
.
type
in
init_op_types
:
return
op
return
None
def
_is_duplicated_init_op
(
op1
,
op2
):
if
op1
.
block
==
op2
.
block
and
\
op1
.
type
==
op2
.
type
and
\
op1
.
input_arg_names
==
op2
.
input_arg_names
and
\
op1
.
output_arg_names
==
op2
.
output_arg_names
and
\
op1
.
idx
!=
op2
.
idx
and
\
op1
.
all_attrs
()
==
op2
.
all_attrs
():
return
True
return
False
class
Initializer
(
object
):
class
Initializer
(
object
):
"""Base class for variable initializers
"""Base class for variable initializers
...
@@ -165,7 +147,6 @@ class ConstantInitializer(Initializer):
...
@@ -165,7 +147,6 @@ class ConstantInitializer(Initializer):
"""
"""
assert
isinstance
(
var
,
framework
.
Variable
)
assert
isinstance
(
var
,
framework
.
Variable
)
assert
isinstance
(
block
,
framework
.
Block
)
assert
isinstance
(
block
,
framework
.
Block
)
init_op
=
_is_inited_by
(
block
,
var
,
[
'fill_constant'
])
# Initialization Ops should be prepended and not appended
# Initialization Ops should be prepended and not appended
op
=
block
.
_prepend_op
(
op
=
block
.
_prepend_op
(
type
=
"fill_constant"
,
type
=
"fill_constant"
,
...
@@ -176,9 +157,6 @@ class ConstantInitializer(Initializer):
...
@@ -176,9 +157,6 @@ class ConstantInitializer(Initializer):
"value"
:
float
(
self
.
_value
),
"value"
:
float
(
self
.
_value
),
'force_cpu'
:
self
.
_force_cpu
or
force_init_on_cpu
()
'force_cpu'
:
self
.
_force_cpu
or
force_init_on_cpu
()
})
})
if
init_op
is
not
None
and
_is_duplicated_init_op
(
init_op
,
op
):
block
.
_remove_op
(
0
)
return
init_op
var
.
op
=
op
var
.
op
=
op
return
op
return
op
...
@@ -221,7 +199,6 @@ class UniformInitializer(Initializer):
...
@@ -221,7 +199,6 @@ class UniformInitializer(Initializer):
"""
"""
assert
isinstance
(
var
,
framework
.
Variable
)
assert
isinstance
(
var
,
framework
.
Variable
)
assert
isinstance
(
block
,
framework
.
Block
)
assert
isinstance
(
block
,
framework
.
Block
)
init_op
=
_is_inited_by
(
block
,
var
,
[
'uniform_random'
])
# Initialization Ops should be prepended and not appended
# Initialization Ops should be prepended and not appended
if
self
.
_seed
==
0
:
if
self
.
_seed
==
0
:
self
.
_seed
=
block
.
program
.
random_seed
self
.
_seed
=
block
.
program
.
random_seed
...
@@ -235,9 +212,6 @@ class UniformInitializer(Initializer):
...
@@ -235,9 +212,6 @@ class UniformInitializer(Initializer):
"max"
:
self
.
_high
,
"max"
:
self
.
_high
,
"seed"
:
self
.
_seed
"seed"
:
self
.
_seed
})
})
if
init_op
is
not
None
and
_is_duplicated_init_op
(
init_op
,
op
):
block
.
_remove_op
(
0
)
return
init_op
var
.
op
=
op
var
.
op
=
op
return
op
return
op
...
@@ -279,7 +253,6 @@ class NormalInitializer(Initializer):
...
@@ -279,7 +253,6 @@ class NormalInitializer(Initializer):
"""
"""
assert
isinstance
(
var
,
framework
.
Variable
)
assert
isinstance
(
var
,
framework
.
Variable
)
assert
isinstance
(
block
,
framework
.
Block
)
assert
isinstance
(
block
,
framework
.
Block
)
init_op
=
_is_inited_by
(
block
,
var
,
[
'gaussian_random'
])
# Initialization Ops should be prepended and not appended
# Initialization Ops should be prepended and not appended
if
self
.
_seed
==
0
:
if
self
.
_seed
==
0
:
self
.
_seed
=
block
.
program
.
random_seed
self
.
_seed
=
block
.
program
.
random_seed
...
@@ -293,9 +266,6 @@ class NormalInitializer(Initializer):
...
@@ -293,9 +266,6 @@ class NormalInitializer(Initializer):
"std"
:
self
.
_std_dev
,
"std"
:
self
.
_std_dev
,
"seed"
:
self
.
_seed
"seed"
:
self
.
_seed
})
})
if
init_op
is
not
None
and
_is_duplicated_init_op
(
init_op
,
op
):
block
.
_remove_op
(
0
)
return
init_op
var
.
op
=
op
var
.
op
=
op
return
op
return
op
...
@@ -365,9 +335,6 @@ class XavierInitializer(Initializer):
...
@@ -365,9 +335,6 @@ class XavierInitializer(Initializer):
"""
"""
assert
isinstance
(
var
,
framework
.
Variable
)
assert
isinstance
(
var
,
framework
.
Variable
)
assert
isinstance
(
block
,
framework
.
Block
)
assert
isinstance
(
block
,
framework
.
Block
)
init_op
=
_is_inited_by
(
block
,
var
,
[
'uniform_random'
,
'gaussian_random'
])
f_in
,
f_out
=
self
.
_compute_fans
(
var
)
f_in
,
f_out
=
self
.
_compute_fans
(
var
)
# If fan_in and fan_out are passed, use them
# If fan_in and fan_out are passed, use them
...
@@ -402,9 +369,6 @@ class XavierInitializer(Initializer):
...
@@ -402,9 +369,6 @@ class XavierInitializer(Initializer):
"std"
:
std
,
"std"
:
std
,
"seed"
:
self
.
_seed
"seed"
:
self
.
_seed
})
})
if
init_op
is
not
None
and
_is_duplicated_init_op
(
init_op
,
op
):
block
.
_remove_op
(
0
)
return
init_op
var
.
op
=
op
var
.
op
=
op
return
op
return
op
...
@@ -470,9 +434,6 @@ class MSRAInitializer(Initializer):
...
@@ -470,9 +434,6 @@ class MSRAInitializer(Initializer):
"""
"""
assert
isinstance
(
var
,
framework
.
Variable
)
assert
isinstance
(
var
,
framework
.
Variable
)
assert
isinstance
(
block
,
framework
.
Block
)
assert
isinstance
(
block
,
framework
.
Block
)
init_op
=
_is_inited_by
(
block
,
var
,
[
'uniform_random'
,
'gaussian_random'
])
f_in
,
f_out
=
self
.
_compute_fans
(
var
)
f_in
,
f_out
=
self
.
_compute_fans
(
var
)
# If fan_in is passed, use it
# If fan_in is passed, use it
...
@@ -506,9 +467,6 @@ class MSRAInitializer(Initializer):
...
@@ -506,9 +467,6 @@ class MSRAInitializer(Initializer):
"std"
:
std
,
"std"
:
std
,
"seed"
:
self
.
_seed
"seed"
:
self
.
_seed
})
})
if
init_op
is
not
None
and
_is_duplicated_init_op
(
init_op
,
op
):
block
.
_remove_op
(
0
)
return
init_op
var
.
op
=
op
var
.
op
=
op
return
op
return
op
...
@@ -574,8 +532,6 @@ class BilinearInitializer(Initializer):
...
@@ -574,8 +532,6 @@ class BilinearInitializer(Initializer):
if
not
isinstance
(
block
,
framework
.
Block
):
if
not
isinstance
(
block
,
framework
.
Block
):
raise
ValueError
(
"block must be framework.Block."
)
raise
ValueError
(
"block must be framework.Block."
)
init_op
=
_is_inited_by
(
block
,
var
,
'assign_value'
)
shape
=
var
.
shape
shape
=
var
.
shape
if
len
(
shape
)
!=
4
:
if
len
(
shape
)
!=
4
:
raise
ValueError
(
"the length of shape must be 4."
)
raise
ValueError
(
"the length of shape must be 4."
)
...
@@ -609,9 +565,6 @@ class BilinearInitializer(Initializer):
...
@@ -609,9 +565,6 @@ class BilinearInitializer(Initializer):
'shape'
:
list
(
shape
),
'shape'
:
list
(
shape
),
value_name
:
values
value_name
:
values
})
})
if
init_op
is
not
None
and
_is_duplicated_init_op
(
init_op
,
op
):
block
.
_remove_op
(
0
)
return
init_op
var
.
op
=
op
var
.
op
=
op
return
op
return
op
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录