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
b785bf77
Commit
b785bf77
authored
Aug 02, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update trainer doc
parent
2d856f94
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
19 deletions
+26
-19
docs/tutorial/trainer.md
docs/tutorial/trainer.md
+25
-18
examples/ResNet/imagenet-resnet.py
examples/ResNet/imagenet-resnet.py
+1
-1
No files found.
docs/tutorial/trainer.md
View file @
b785bf77
...
@@ -5,37 +5,44 @@ Training is **running something again and again**.
...
@@ -5,37 +5,44 @@ Training is **running something again and again**.
Tensorpack base trainer implements the logic of __running the iteration__.
Tensorpack base trainer implements the logic of __running the iteration__.
Users or derived trainers should implement __what the iteration is__.
Users or derived trainers should implement __what the iteration is__.
### Common Trainers
Most neural network training tasks are single-cost optimization.
Most neural network training tasks are single-cost optimization.
Tensorpack provides some trainer implementations for such tasks.
Tensorpack provides some trainer implementations for such tasks.
These trainers will build the graph based on the given
`ModelDesc`
, and minimizes
`ModelDesc.cost`
.
These trainers will build the graph based on the given
`ModelDesc`
, and minimizes
`ModelDesc.cost`
.
Existing trainers were implemented with certain prefetch mechanism,
which will run significantly faster than a naive
`sess.run(..., feed_dict={...})`
.
There are also Multi-GPU trainers which include the logic of data-parallel Multi-GPU training.
You can enable them by just one line, and all the necessary logic to achieve the best performance was baked into the trainers already.
For example, SyncMultiGPUTrainer can train ResNet50 as fast as the
[
official tensorflow benchmark
](
https://github.com/tensorflow/benchmarks
)
.
To use trainers, pass a
`TrainConfig`
to configure them:
To use trainers, pass a
`TrainConfig`
to configure them:
```
python
```
python
config
=
TrainConfig
(
config
=
TrainConfig
(
model
=
MyModel
()
model
=
MyModel
()
dataflow
=
my_dataflow
,
dataflow
=
my_dataflow
,
# data=my_inputsource, # alternatively, use a customized InputSource
callbacks
=
[
...
]
callbacks
=
[
...
]
)
)
# start training (with a slow trainer. See 'tutorials - Input Pipeline' for details):
# start training:
# SimpleTrainer(config).train()
SomeTrainer
(
config
,
other_arguments
)
.
train
()
# start training with queue prefetch:
QueueInputTrainer
(
config
)
.
train
()
# start multi-GPU training with a synchronous update:
# start multi-GPU training with a synchronous update:
# SyncMultiGPUTrainer(config).train()
# SyncMultiGPUTrainer
ParameterServer
(config).train()
```
```
Trainers just run __some__ iterations, so there is no limit in where the data come from
When you set the DataFlow (rather than the InputSource) in the config,
or what to do in an iteration.
tensorpack trainers automatically pick up certain prefetch mechanism,
For example,
[
GAN trainer
](
../examples/GAN/GAN.py
)
minimizes
which will run faster than a naive
`sess.run(..., feed_dict={...})`
.
two cost functions alternatively.
You can set the InputSource instead, to customize this behavior.
Existing multi-GPU trainers include the logic of data-parallel training.
You can enable them by just one line, and all the necessary logic to achieve the best performance was baked into the trainers already.
The trainers can reach the same performance as the
[
official tensorflow benchmark
](
https://github.com/tensorflow/benchmarks
)
.
Please note that, in data-parallel training, all towers (all replicates of the model) will take
tensors from the InputSource (instead of taking one for all and split). So the total batch size
would be multiplied by the number of GPUs.
### Custom Trainers
Trainers just run __some__ iterations, so there is no limit in where the data come from or what to do in an iteration.
For example,
[
GAN trainer
](
../examples/GAN/GAN.py
)
minimizes two cost functions alternatively.
examples/ResNet/imagenet-resnet.py
View file @
b785bf77
...
@@ -106,7 +106,7 @@ def get_config(fake=False, data_format='NCHW'):
...
@@ -106,7 +106,7 @@ def get_config(fake=False, data_format='NCHW'):
ClassificationError
(
'wrong-top1'
,
'val-error-top1'
),
ClassificationError
(
'wrong-top1'
,
'val-error-top1'
),
ClassificationError
(
'wrong-top5'
,
'val-error-top5'
)]),
ClassificationError
(
'wrong-top5'
,
'val-error-top5'
)]),
ScheduledHyperParamSetter
(
'learning_rate'
,
ScheduledHyperParamSetter
(
'learning_rate'
,
[(
30
,
1e-2
),
(
60
,
1e-3
),
(
85
,
1e-4
),
(
95
,
1e-5
)]),
[(
30
,
1e-2
),
(
60
,
1e-3
),
(
85
,
1e-4
),
(
95
,
1e-5
)
,
(
105
,
1e-6
)
]),
HumanHyperParamSetter
(
'learning_rate'
),
HumanHyperParamSetter
(
'learning_rate'
),
],
],
steps_per_epoch
=
5000
,
steps_per_epoch
=
5000
,
...
...
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