Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
models
提交
eb7eb9cd
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看板
未验证
提交
eb7eb9cd
编写于
7月 30, 2020
作者:
L
littletomatodonkey
提交者:
GitHub
7月 30, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
remove unused code in ml (#4781)
上级
a7fb45f6
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
42 deletion
+27
-42
PaddleCV/metric_learning/train_elem.py
PaddleCV/metric_learning/train_elem.py
+13
-20
PaddleCV/metric_learning/train_pair.py
PaddleCV/metric_learning/train_pair.py
+14
-22
未找到文件。
PaddleCV/metric_learning/train_elem.py
浏览文件 @
eb7eb9cd
...
...
@@ -109,14 +109,13 @@ def build_program(is_train, main_prog, startup_prog, args):
with
fluid
.
program_guard
(
main_prog
,
startup_prog
):
queue_capacity
=
64
image
=
fluid
.
data
(
name
=
'image'
,
shape
=
[
None
]
+
image_shape
,
dtype
=
'float32'
)
label
=
fluid
.
data
(
name
=
'label'
,
shape
=
[
None
,
1
],
dtype
=
'int64'
)
name
=
'image'
,
shape
=
[
None
]
+
image_shape
,
dtype
=
'float32'
)
label
=
fluid
.
data
(
name
=
'label'
,
shape
=
[
None
,
1
],
dtype
=
'int64'
)
loader
=
fluid
.
io
.
DataLoader
.
from_generator
(
feed_list
=
[
image
,
label
],
capacity
=
queue_capacity
,
use_double_buffer
=
True
,
iterable
=
True
)
feed_list
=
[
image
,
label
],
capacity
=
queue_capacity
,
use_double_buffer
=
True
,
iterable
=
True
)
with
fluid
.
unique_name
.
guard
():
avg_cost
,
acc_top1
,
acc_top5
,
out
=
net_config
(
image
,
label
,
model
,
...
...
@@ -187,17 +186,12 @@ def train_async(args):
exe
.
run
(
startup_prog
)
logging
.
debug
(
'after run startup program'
)
if
checkpoint
is
not
None
:
fluid
.
load
(
program
=
train_prog
,
model_path
=
checkpoint
,
executor
=
exe
)
if
pretrained_model
:
def
if_exist
(
var
):
return
os
.
path
.
exists
(
os
.
path
.
join
(
pretrained_model
,
var
.
name
))
fluid
.
load
(
program
=
train_prog
,
model_path
=
pretrained_model
,
executor
=
exe
)
fluid
.
load
(
program
=
train_prog
,
model_path
=
pretrained_model
,
executor
=
exe
)
if
args
.
use_gpu
:
devicenum
=
get_gpu_num
()
...
...
@@ -208,7 +202,7 @@ def train_async(args):
test_batch_size
=
args
.
test_batch_size
train_loader
.
set_sample_generator
(
reader
.
train
(
args
),
reader
.
train
(
args
),
batch_size
=
train_batch_size
,
drop_last
=
True
,
places
=
places
)
...
...
@@ -230,9 +224,8 @@ def train_async(args):
while
iter_no
<=
args
.
total_iter_num
:
for
train_batch
in
train_loader
():
t1
=
time
.
time
()
lr
,
loss
,
acc1
,
acc5
=
train_exe
.
run
(
feed
=
train_batch
,
fetch_list
=
train_fetch_list
)
lr
,
loss
,
acc1
,
acc5
=
train_exe
.
run
(
feed
=
train_batch
,
fetch_list
=
train_fetch_list
)
t2
=
time
.
time
()
period
=
t2
-
t1
lr
=
np
.
mean
(
np
.
array
(
lr
))
...
...
@@ -260,8 +253,8 @@ def train_async(args):
for
batch_id
,
test_batch
in
enumerate
(
test_loader
()):
t1
=
time
.
time
()
[
feas
]
=
exe
.
run
(
test_prog
,
feed
=
test_batch
,
fetch_list
=
test_fetch_list
)
feed
=
test_batch
,
fetch_list
=
test_fetch_list
)
label
=
np
.
asarray
(
test_batch
[
0
][
'label'
])
label
=
np
.
squeeze
(
label
)
...
...
PaddleCV/metric_learning/train_pair.py
浏览文件 @
eb7eb9cd
...
...
@@ -116,14 +116,13 @@ def build_program(is_train, main_prog, startup_prog, args):
with
fluid
.
program_guard
(
main_prog
,
startup_prog
):
queue_capacity
=
64
image
=
fluid
.
data
(
name
=
'image'
,
shape
=
[
None
]
+
image_shape
,
dtype
=
'float32'
)
label
=
fluid
.
data
(
name
=
'label'
,
shape
=
[
None
,
1
],
dtype
=
'int64'
)
name
=
'image'
,
shape
=
[
None
]
+
image_shape
,
dtype
=
'float32'
)
label
=
fluid
.
data
(
name
=
'label'
,
shape
=
[
None
,
1
],
dtype
=
'int64'
)
loader
=
fluid
.
io
.
DataLoader
.
from_generator
(
feed_list
=
[
image
,
label
],
capacity
=
queue_capacity
,
use_double_buffer
=
True
,
iterable
=
True
)
feed_list
=
[
image
,
label
],
capacity
=
queue_capacity
,
use_double_buffer
=
True
,
iterable
=
True
)
with
fluid
.
unique_name
.
guard
():
avg_cost
,
out
=
net_config
(
image
,
label
,
model
,
args
,
is_train
)
...
...
@@ -185,18 +184,12 @@ def train_async(args):
exe
.
run
(
startup_prog
)
logging
.
debug
(
'after run startup program'
)
if
checkpoint
is
not
None
:
fluid
.
load
(
program
=
train_prog
,
model_path
=
checkpoint
,
executor
=
exe
)
if
pretrained_model
:
def
if_exist
(
var
):
return
os
.
path
.
exists
(
os
.
path
.
join
(
pretrained_model
,
var
.
name
))
fluid
.
load
(
program
=
train_prog
,
model_path
=
pretrained_model
,
executor
=
exe
)
fluid
.
load
(
program
=
train_prog
,
model_path
=
pretrained_model
,
executor
=
exe
)
if
args
.
use_gpu
:
devicenum
=
get_gpu_num
()
...
...
@@ -207,7 +200,7 @@ def train_async(args):
test_batch_size
=
args
.
test_batch_size
train_loader
.
set_sample_generator
(
reader
.
train
(
args
),
reader
.
train
(
args
),
batch_size
=
train_batch_size
,
drop_last
=
True
,
places
=
places
)
...
...
@@ -229,9 +222,8 @@ def train_async(args):
while
iter_no
<=
args
.
total_iter_num
:
for
train_batch
in
train_loader
():
t1
=
time
.
time
()
lr
,
loss
,
feas
,
label
=
train_exe
.
run
(
feed
=
train_batch
,
fetch_list
=
train_fetch_list
)
lr
,
loss
,
feas
,
label
=
train_exe
.
run
(
feed
=
train_batch
,
fetch_list
=
train_fetch_list
)
t2
=
time
.
time
()
period
=
t2
-
t1
lr
=
np
.
mean
(
np
.
array
(
lr
))
...
...
@@ -257,8 +249,8 @@ def train_async(args):
for
batch_id
,
test_batch
in
enumerate
(
test_loader
()):
t1
=
time
.
time
()
[
feas
]
=
exe
.
run
(
test_prog
,
feed
=
test_batch
,
fetch_list
=
test_fetch_list
)
feed
=
test_batch
,
fetch_list
=
test_fetch_list
)
label
=
np
.
asarray
(
test_batch
[
0
][
'label'
])
label
=
np
.
squeeze
(
label
)
...
...
@@ -280,7 +272,7 @@ def train_async(args):
if
iter_no
%
args
.
save_iter_step
==
0
and
iter_no
!=
0
:
model_path
=
os
.
path
.
join
(
model_save_dir
+
'/'
+
model_name
,
str
(
iter_no
))
str
(
iter_no
))
if
not
os
.
path
.
isdir
(
model_path
):
os
.
makedirs
(
model_path
)
fluid
.
save
(
program
=
train_prog
,
model_path
=
model_path
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录