Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
823d914c
M
models
项目概览
PaddlePaddle
/
models
大约 1 年 前同步成功
通知
222
Star
6828
Fork
2962
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
602
列表
看板
标记
里程碑
合并请求
255
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
models
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
602
Issue
602
列表
看板
标记
里程碑
合并请求
255
合并请求
255
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
823d914c
编写于
5月 15, 2020
作者:
Z
zhiqiu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change dataset to flowers, test=develop
上级
9d2346a5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
2 deletion
+20
-2
PaddleCV/image_classification/scripts/train/ResNet101.sh
PaddleCV/image_classification/scripts/train/ResNet101.sh
+2
-2
PaddleCV/image_classification/train.py
PaddleCV/image_classification/train.py
+18
-0
未找到文件。
PaddleCV/image_classification/scripts/train/ResNet101.sh
浏览文件 @
823d914c
...
...
@@ -6,9 +6,9 @@ export FLAGS_eager_delete_tensor_gb=0.0
export
FLAGS_fraction_of_gpu_memory_to_use
=
0.98
#ResNet101:
python train.py
\
python
3
train.py
\
--model
=
ResNet101
\
--batch_size
=
256
\
--batch_size
=
1024
\
--model_save_dir
=
output/
\
--lr_strategy
=
piecewise_decay
\
--num_epochs
=
120
\
...
...
PaddleCV/image_classification/train.py
浏览文件 @
823d914c
...
...
@@ -79,6 +79,8 @@ def build_program(is_train, main_prog, startup_prog, args):
use_dynamic_loss_scaling
=
args
.
use_dynamic_loss_scaling
)
optimizer
.
minimize
(
avg_cost
)
# print(main_prog)
# return
if
args
.
use_ema
:
global_steps
=
fluid
.
layers
.
learning_rate_scheduler
.
_decay_step_counter
(
)
...
...
@@ -151,6 +153,14 @@ def validate(args,
device_num
=
device_num
)
def
reader_decorator
(
reader
):
def
__reader__
():
for
item
in
reader
():
img
=
np
.
array
(
item
[
0
]).
astype
(
'float32'
).
reshape
(
3
,
224
,
224
)
label
=
np
.
array
(
item
[
1
]).
astype
(
'int64'
).
reshape
(
1
)
yield
img
,
label
return
__reader__
def
train
(
args
):
"""Train model
...
...
@@ -206,6 +216,12 @@ def train(args):
else
:
imagenet_reader
=
reader
.
ImageNetReader
(
0
if
num_trainers
>
1
else
None
)
train_reader
=
imagenet_reader
.
train
(
settings
=
args
)
train_reader
=
paddle
.
batch
(
reader_decorator
(
paddle
.
dataset
.
flowers
.
train
(
use_xmap
=
True
)),
batch_size
=
args
.
batch_size
,
drop_last
=
True
)
if
args
.
use_gpu
:
if
num_trainers
<=
1
:
places
=
fluid
.
framework
.
cuda_places
()
...
...
@@ -261,6 +277,7 @@ def train(args):
sys
.
stdout
.
flush
()
train_batch_id
+=
1
t1
=
time
.
time
()
#NOTE: this for benchmark profiler
total_batch_num
=
total_batch_num
+
1
if
args
.
is_profiler
and
pass_id
==
0
and
train_batch_id
==
args
.
print_step
:
...
...
@@ -290,6 +307,7 @@ def train(args):
if
trainer_id
==
0
and
pass_id
%
args
.
save_step
==
0
:
save_model
(
args
,
exe
,
train_prog
,
pass_id
)
def
main
():
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录