Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
71d62207
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看板
未验证
提交
71d62207
编写于
11月 04, 2020
作者:
L
Leo Chen
提交者:
GitHub
11月 04, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Skip reader op in mixed_precision decorator (#28353)
* skip reader op in mixed_precision decorator * add ut
上级
8b2436a7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
45 addition
and
0 deletion
+45
-0
python/paddle/fluid/contrib/mixed_precision/fp16_utils.py
python/paddle/fluid/contrib/mixed_precision/fp16_utils.py
+8
-0
python/paddle/fluid/contrib/tests/test_image_classification_fp16.py
...dle/fluid/contrib/tests/test_image_classification_fp16.py
+37
-0
未找到文件。
python/paddle/fluid/contrib/mixed_precision/fp16_utils.py
浏览文件 @
71d62207
...
...
@@ -215,6 +215,14 @@ def rewrite_program(main_prog, amp_lists):
white_op_set
=
set
()
black_op_set
=
set
()
for
op
in
ops
:
# NOTE(zhiqiu): 'create_py_reader' and 'read' is used in non-iterable DataLoder,
# we don't need to handle reader op and the input of 'create_py_reader' is not
# in block, which may result in errors.
# See GeneratorLoader._init_non_iterable() for details.
if
op
.
type
==
'create_py_reader'
or
op
.
type
==
'read'
:
continue
if
amp_lists
.
black_varnames
is
not
None
and
_is_in_black_varnames
(
op
,
amp_lists
):
black_op_set
.
add
(
op
)
...
...
python/paddle/fluid/contrib/tests/test_image_classification_fp16.py
浏览文件 @
71d62207
...
...
@@ -417,5 +417,42 @@ class TestImageClassification(unittest.TestCase):
yield
class
TestAmpWithNonIterableDataLoader
(
unittest
.
TestCase
):
def
decorate_with_data_loader
(
self
):
main_prog
=
paddle
.
static
.
Program
()
start_prog
=
paddle
.
static
.
Program
()
with
paddle
.
static
.
program_guard
(
main_prog
,
start_prog
):
with
paddle
.
fluid
.
unique_name
.
guard
():
image
=
fluid
.
layers
.
data
(
name
=
'image'
,
shape
=
[
3
,
224
,
224
],
dtype
=
'float32'
)
label
=
fluid
.
layers
.
data
(
name
=
'label'
,
shape
=
[
1
],
dtype
=
'int64'
)
py_reader
=
fluid
.
io
.
DataLoader
.
from_generator
(
feed_list
=
[
image
,
label
],
capacity
=
4
,
iterable
=
False
,
use_double_buffer
=
False
)
net
=
vgg16_bn_drop
(
image
)
logits
=
fluid
.
layers
.
fc
(
input
=
net
,
size
=
10
,
act
=
"softmax"
)
cost
,
predict
=
fluid
.
layers
.
softmax_with_cross_entropy
(
logits
,
label
,
return_softmax
=
True
)
avg_cost
=
fluid
.
layers
.
mean
(
cost
)
optimizer
=
fluid
.
optimizer
.
Lamb
(
learning_rate
=
0.001
)
amp_lists
=
fluid
.
contrib
.
mixed_precision
.
AutoMixedPrecisionLists
(
custom_black_varnames
=
{
"loss"
,
"conv2d_0.w_0"
})
mp_optimizer
=
fluid
.
contrib
.
mixed_precision
.
decorate
(
optimizer
=
optimizer
,
amp_lists
=
amp_lists
,
init_loss_scaling
=
8.0
,
use_dynamic_loss_scaling
=
True
)
mp_optimizer
.
minimize
(
avg_cost
)
def
test_non_iterable_dataloader
(
self
):
self
.
decorate_with_data_loader
()
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录