Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
d3fc3d55
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
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看板
提交
d3fc3d55
编写于
4月 01, 2019
作者:
L
lujun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move internal function, test=develop
上级
2b32302b
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
21 addition
and
21 deletion
+21
-21
python/paddle/fluid/tests/unittests/test_imperative_basic.py
python/paddle/fluid/tests/unittests/test_imperative_basic.py
+5
-5
python/paddle/fluid/tests/unittests/test_imperative_deepcf.py
...on/paddle/fluid/tests/unittests/test_imperative_deepcf.py
+1
-1
python/paddle/fluid/tests/unittests/test_imperative_gan.py
python/paddle/fluid/tests/unittests/test_imperative_gan.py
+2
-2
python/paddle/fluid/tests/unittests/test_imperative_mnist.py
python/paddle/fluid/tests/unittests/test_imperative_mnist.py
+3
-3
python/paddle/fluid/tests/unittests/test_imperative_optimizer.py
...paddle/fluid/tests/unittests/test_imperative_optimizer.py
+3
-3
python/paddle/fluid/tests/unittests/test_imperative_ptb_rnn.py
...n/paddle/fluid/tests/unittests/test_imperative_ptb_rnn.py
+1
-1
python/paddle/fluid/tests/unittests/test_imperative_resnet.py
...on/paddle/fluid/tests/unittests/test_imperative_resnet.py
+1
-1
python/paddle/fluid/tests/unittests/test_imperative_se_resnext.py
...addle/fluid/tests/unittests/test_imperative_se_resnext.py
+4
-4
python/paddle/fluid/tests/unittests/test_imperative_transformer.py
...ddle/fluid/tests/unittests/test_imperative_transformer.py
+1
-1
未找到文件。
python/paddle/fluid/tests/unittests/test_imperative_basic.py
浏览文件 @
d3fc3d55
...
...
@@ -200,7 +200,7 @@ class TestImperative(unittest.TestCase):
inputs
.
append
(
fluid
.
dygraph
.
base
.
to_variable
(
x
))
ret
=
fluid
.
layers
.
sums
(
inputs
)
loss
=
fluid
.
layers
.
reduce_sum
(
ret
)
loss
.
_
backward
()
loss
.
backward
()
self
.
assertTrue
(
np
.
allclose
(
ret
.
numpy
(),
x
*
10
))
self
.
assertTrue
(
np
.
allclose
(
inputs
[
0
].
gradient
(),
x
))
...
...
@@ -258,7 +258,7 @@ class TestImperative(unittest.TestCase):
var_inp
=
fluid
.
dygraph
.
base
.
to_variable
(
np_inp
)
outs
=
my_py_layer
(
var_inp
)
dy_out
=
np
.
sum
(
outs
[
0
].
numpy
())
outs
[
0
].
_
backward
()
outs
[
0
].
backward
()
dy_grad
=
var_inp
.
gradient
()
with
new_program_scope
():
...
...
@@ -288,7 +288,7 @@ class TestImperative(unittest.TestCase):
x
=
l
(
var_inp
)[
0
]
self
.
assertIsNotNone
(
x
)
dy_out
=
x
.
numpy
()
x
.
_
backward
()
x
.
backward
()
dy_grad
=
l
.
_x_for_debug
.
gradient
()
with
new_program_scope
():
...
...
@@ -315,7 +315,7 @@ class TestImperative(unittest.TestCase):
mlp
=
MLP
(
"mlp"
)
out
=
mlp
(
var_inp
)
dy_out
=
out
.
numpy
()
out
.
_
backward
()
out
.
backward
()
dy_grad
=
mlp
.
_fc1
.
_w
.
gradient
()
with
new_program_scope
():
...
...
@@ -359,7 +359,7 @@ class TestImperative(unittest.TestCase):
simple_rnn
=
SimpleRNN
(
"simple_rnn"
)
outs
,
pre_hiddens
=
simple_rnn
.
forward
(
var_inp
)
dy_out
=
outs
[
3
].
numpy
()
outs
[
3
].
_
backward
()
outs
[
3
].
backward
()
dy_grad_h2o
=
simple_rnn
.
_cell
.
_h2o_w
.
gradient
()
dy_grad_h2h
=
simple_rnn
.
_cell
.
_h2h_w
.
gradient
()
dy_grad_i2h
=
simple_rnn
.
_cell
.
_i2h_w
.
gradient
()
...
...
python/paddle/fluid/tests/unittests/test_imperative_deepcf.py
浏览文件 @
d3fc3d55
...
...
@@ -252,7 +252,7 @@ class TestDygraphDeepCF(unittest.TestCase):
fluid
.
layers
.
log_loss
(
prediction
,
to_variable
(
labels_np
[
slice
:
slice
+
BATCH_SIZE
])))
loss
.
_
backward
()
loss
.
backward
()
adam
.
minimize
(
loss
)
deepcf
.
clear_gradients
()
dy_loss
=
loss
.
numpy
()
...
...
python/paddle/fluid/tests/unittests/test_imperative_gan.py
浏览文件 @
d3fc3d55
...
...
@@ -150,7 +150,7 @@ class TestDygraphGAN(unittest.TestCase):
x
=
d_fake
,
label
=
to_variable
(
np
.
zeros
([
2
,
1
],
np
.
float32
))))
d_loss
=
d_loss_real
+
d_loss_fake
d_loss
.
_
backward
()
d_loss
.
backward
()
sgd
.
minimize
(
d_loss
)
discriminator
.
clear_gradients
()
generator
.
clear_gradients
()
...
...
@@ -160,7 +160,7 @@ class TestDygraphGAN(unittest.TestCase):
g_loss
=
fluid
.
layers
.
reduce_mean
(
fluid
.
layers
.
sigmoid_cross_entropy_with_logits
(
x
=
d_fake
,
label
=
to_variable
(
np
.
ones
([
2
,
1
],
np
.
float32
))))
g_loss
.
_
backward
()
g_loss
.
backward
()
sgd
.
minimize
(
g_loss
)
for
p
in
discriminator
.
parameters
():
dy_params
[
p
.
name
]
=
p
.
numpy
()
...
...
python/paddle/fluid/tests/unittests/test_imperative_mnist.py
浏览文件 @
d3fc3d55
...
...
@@ -134,11 +134,11 @@ class TestImperativeMnist(unittest.TestCase):
loss
=
fluid
.
layers
.
cross_entropy
(
cost
,
label
)
avg_loss
=
fluid
.
layers
.
mean
(
loss
)
dy_out
=
avg_loss
.
_
numpy
()
dy_out
=
avg_loss
.
numpy
()
if
epoch
==
0
and
batch_id
==
0
:
for
param
in
mnist
.
parameters
():
dy_param_init_value
[
param
.
name
]
=
param
.
_
numpy
()
dy_param_init_value
[
param
.
name
]
=
param
.
numpy
()
avg_loss
.
_backward
()
sgd
.
minimize
(
avg_loss
)
...
...
@@ -146,7 +146,7 @@ class TestImperativeMnist(unittest.TestCase):
dy_param_value
=
{}
for
param
in
mnist
.
parameters
():
dy_param_value
[
param
.
name
]
=
param
.
_
numpy
()
dy_param_value
[
param
.
name
]
=
param
.
numpy
()
with
new_program_scope
():
fluid
.
default_startup_program
().
random_seed
=
seed
...
...
python/paddle/fluid/tests/unittests/test_imperative_optimizer.py
浏览文件 @
d3fc3d55
...
...
@@ -75,18 +75,18 @@ class TestImperativeOptimizerBase(unittest.TestCase):
cost
=
mlp
(
img
)
avg_loss
=
fluid
.
layers
.
reduce_mean
(
cost
)
dy_out
=
avg_loss
.
_
numpy
()
dy_out
=
avg_loss
.
numpy
()
if
batch_id
==
0
:
for
param
in
mlp
.
parameters
():
dy_param_init_value
[
param
.
name
]
=
param
.
_
numpy
()
dy_param_init_value
[
param
.
name
]
=
param
.
numpy
()
avg_loss
.
_backward
()
optimizer
.
minimize
(
avg_loss
)
mlp
.
clear_gradients
()
dy_param_value
=
{}
for
param
in
mlp
.
parameters
():
dy_param_value
[
param
.
name
]
=
param
.
_
numpy
()
dy_param_value
[
param
.
name
]
=
param
.
numpy
()
with
new_program_scope
():
fluid
.
default_startup_program
().
random_seed
=
seed
...
...
python/paddle/fluid/tests/unittests/test_imperative_ptb_rnn.py
浏览文件 @
d3fc3d55
...
...
@@ -261,7 +261,7 @@ class TestDygraphPtbRnn(unittest.TestCase):
if
i
==
0
:
for
param
in
ptb_model
.
parameters
():
dy_param_init
[
param
.
name
]
=
param
.
numpy
()
dy_loss
.
_
backward
()
dy_loss
.
backward
()
sgd
.
minimize
(
dy_loss
)
ptb_model
.
clear_gradients
()
if
i
==
batch_num
-
1
:
...
...
python/paddle/fluid/tests/unittests/test_imperative_resnet.py
浏览文件 @
d3fc3d55
...
...
@@ -273,7 +273,7 @@ class TestDygraphResnet(unittest.TestCase):
if
param
.
name
not
in
dy_param_init_value
:
dy_param_init_value
[
param
.
name
]
=
param
.
numpy
()
avg_loss
.
_
backward
()
avg_loss
.
backward
()
dy_grad_value
=
{}
for
param
in
resnet
.
parameters
():
...
...
python/paddle/fluid/tests/unittests/test_imperative_se_resnext.py
浏览文件 @
d3fc3d55
...
...
@@ -331,7 +331,7 @@ class TestImperativeResneXt(unittest.TestCase):
dy_param_init_value
=
{}
for
param
in
se_resnext
.
parameters
():
dy_param_init_value
[
param
.
name
]
=
param
.
_
numpy
()
dy_param_init_value
[
param
.
name
]
=
param
.
numpy
()
for
batch_id
,
data
in
enumerate
(
train_reader
()):
if
batch_id
>=
batch_num
:
...
...
@@ -350,12 +350,12 @@ class TestImperativeResneXt(unittest.TestCase):
loss
=
fluid
.
layers
.
cross_entropy
(
input
=
out
,
label
=
label
)
avg_loss
=
fluid
.
layers
.
mean
(
x
=
loss
)
dy_out
=
avg_loss
.
_
numpy
()
dy_out
=
avg_loss
.
numpy
()
if
batch_id
==
0
:
for
param
in
se_resnext
.
parameters
():
if
param
.
name
not
in
dy_param_init_value
:
dy_param_init_value
[
param
.
name
]
=
param
.
_
numpy
()
dy_param_init_value
[
param
.
name
]
=
param
.
numpy
()
avg_loss
.
_backward
()
...
...
@@ -372,7 +372,7 @@ class TestImperativeResneXt(unittest.TestCase):
dy_param_value
=
{}
for
param
in
se_resnext
.
parameters
():
dy_param_value
[
param
.
name
]
=
param
.
_
numpy
()
dy_param_value
[
param
.
name
]
=
param
.
numpy
()
with
new_program_scope
():
fluid
.
default_startup_program
().
random_seed
=
seed
...
...
python/paddle/fluid/tests/unittests/test_imperative_transformer.py
浏览文件 @
d3fc3d55
...
...
@@ -995,7 +995,7 @@ class TestDygraphTransformer(unittest.TestCase):
for
param
in
transformer
.
parameters
():
dy_param_init
[
param
.
name
]
=
param
.
numpy
()
dy_avg_cost
.
_
backward
()
dy_avg_cost
.
backward
()
optimizer
.
minimize
(
dy_avg_cost
)
transformer
.
clear_gradients
()
if
i
==
batch_num
-
1
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录