Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wangsen
paddle_dbnet
Commits
40023f76
Commit
40023f76
authored
Nov 24, 2020
by
WenmuZhou
Browse files
修复ips和batch_cost输出错误的bug
parent
0c287c41
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
12 deletions
+14
-12
tools/program.py
tools/program.py
+14
-12
No files found.
tools/program.py
View file @
40023f76
...
...
@@ -236,7 +236,6 @@ def train(config,
train_batch_cost
=
0.0
train_reader_cost
=
0.0
batch_sum
=
0
batch_start
=
time
.
time
()
# eval
if
global_step
>
start_eval_step
and
\
(
global_step
-
start_eval_step
)
%
eval_batch_step
==
0
and
dist
.
get_rank
()
==
0
:
...
...
@@ -275,6 +274,7 @@ def train(config,
best_model_dict
[
main_indicator
],
global_step
)
global_step
+=
1
batch_start
=
time
.
time
()
if
dist
.
get_rank
()
==
0
:
save_model
(
model
,
...
...
@@ -334,17 +334,19 @@ def eval(model, valid_dataloader, post_process_class, eval_class):
def
save_inference_mode
(
model
,
config
,
logger
):
model
.
eval
()
save_path
=
'{}/infer/{}'
.
format
(
config
[
'Global'
][
'save_model_dir'
],
config
[
'Architecture'
][
'model_type'
])
if
config
[
'Architecture'
][
'model_type'
]
==
'rec'
:
input_shape
=
[
None
,
3
,
32
,
None
]
jit_model
=
paddle
.
jit
.
to_static
(
model
,
input_spec
=
[
paddle
.
static
.
InputSpec
(
input_shape
)])
paddle
.
jit
.
save
(
jit_model
,
save_path
)
logger
.
info
(
'inference model save to {}'
.
format
(
save_path
))
model
.
train
()
if
dist
.
get_rank
()
==
0
:
model
.
eval
()
print
(
'infer'
)
save_path
=
'{}/infer/{}'
.
format
(
config
[
'Global'
][
'save_model_dir'
],
config
[
'Architecture'
][
'model_type'
])
if
config
[
'Architecture'
][
'model_type'
]
==
'rec'
:
input_shape
=
[
None
,
3
,
32
,
None
]
jit_model
=
paddle
.
jit
.
to_static
(
model
,
input_spec
=
[
paddle
.
static
.
InputSpec
(
input_shape
)])
paddle
.
jit
.
save
(
jit_model
,
save_path
)
logger
.
info
(
'inference model save to {}'
.
format
(
save_path
))
model
.
train
()
def
preprocess
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment