Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
seminar-breakout
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shashank Suhas
seminar-breakout
Commits
1cd4a380
Commit
1cd4a380
authored
Jun 22, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Loaded epoch number doesn't take effect before training has started.
parent
ab8503e8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
+16
-7
examples/ResNet/imagenet-resnet.py
examples/ResNet/imagenet-resnet.py
+4
-3
tensorpack/train/base.py
tensorpack/train/base.py
+12
-4
No files found.
examples/ResNet/imagenet-resnet.py
View file @
1cd4a380
...
...
@@ -251,6 +251,7 @@ if __name__ == '__main__':
args
=
parser
.
parse_args
()
DEPTH
=
args
.
depth
if
args
.
gpu
:
os
.
environ
[
'CUDA_VISIBLE_DEVICES'
]
=
args
.
gpu
if
args
.
eval
:
...
...
@@ -258,12 +259,12 @@ if __name__ == '__main__':
eval_on_ILSVRC12
(
args
.
load
,
args
.
data
)
sys
.
exit
()
NR_GPU
=
len
(
args
.
gpu
.
split
(
','
)
)
NR_GPU
=
get_nr_gpu
(
)
BATCH_SIZE
=
TOTAL_BATCH_SIZE
//
NR_GPU
logger
.
set_logger_dir
(
os
.
path
.
join
(
'train_log'
,
'imagenet-resnet-d'
+
str
(
DEPTH
)))
logger
.
info
(
"
Batch size per GPU: "
+
str
(
BATCH_SIZE
))
logger
.
info
(
"
Running on {} GPUs. Batch size per GPU: {}"
.
format
(
NR_GPU
,
BATCH_SIZE
))
config
=
get_config
(
fake
=
args
.
fake
,
data_format
=
args
.
data_format
)
if
args
.
load
:
config
.
session_init
=
SaverRestore
(
args
.
load
)
...
...
tensorpack/train/base.py
View file @
1cd4a380
...
...
@@ -58,11 +58,19 @@ class Trainer(object):
self
.
config
=
config
self
.
model
=
config
.
model
self
.
epoch_num
=
self
.
config
.
starting_epoch
-
1
self
.
local_step
=
-
1
self
.
_callbacks
=
[]
self
.
monitors
=
[]
self
.
_epoch_num
=
None
@
property
def
epoch_num
(
self
):
if
self
.
_epoch_num
is
not
None
:
# has started training
return
self
.
_epoch_num
else
:
return
self
.
config
.
starting_epoch
-
1
def
register_callback
(
self
,
cb
):
"""
...
...
@@ -170,9 +178,9 @@ class Trainer(object):
self
.
_callbacks
.
before_train
()
# refresh global step (might have changed by callbacks) TODO ugly
self
.
_starting_step
=
get_global_step_value
()
for
self
.
epoch_num
in
range
(
for
self
.
_
epoch_num
in
range
(
self
.
config
.
starting_epoch
,
self
.
config
.
max_epoch
+
1
):
logger
.
info
(
"Start Epoch {} ..."
.
format
(
self
.
epoch_num
))
logger
.
info
(
"Start Epoch {} ..."
.
format
(
self
.
_
epoch_num
))
start_time
=
time
.
time
()
self
.
_callbacks
.
before_epoch
()
for
self
.
local_step
in
range
(
self
.
config
.
steps_per_epoch
):
...
...
@@ -182,7 +190,7 @@ class Trainer(object):
self
.
_callbacks
.
trigger_step
()
self
.
_callbacks
.
after_epoch
()
logger
.
info
(
"Epoch {} (global_step {}) finished, time:{:.2f} sec."
.
format
(
self
.
epoch_num
,
self
.
global_step
,
time
.
time
()
-
start_time
))
self
.
_
epoch_num
,
self
.
global_step
,
time
.
time
()
-
start_time
))
# trigger epoch outside the timing region.
self
.
_trigger_epoch
()
...
...
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