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
9ecf87de
Commit
9ecf87de
authored
Oct 25, 2017
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
docs update & StagingInputWrapper -> StagingInput
parent
73c66c18
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
49 additions
and
48 deletions
+49
-48
.github/ISSUE_TEMPLATE.md
.github/ISSUE_TEMPLATE.md
+3
-2
CHANGES.md
CHANGES.md
+2
-2
docs/conf.py
docs/conf.py
+1
-0
docs/tutorial/trainer.md
docs/tutorial/trainer.md
+25
-30
examples/GAN/GAN.py
examples/GAN/GAN.py
+2
-2
tensorpack/callbacks/inference_runner.py
tensorpack/callbacks/inference_runner.py
+1
-1
tensorpack/input_source/input_source.py
tensorpack/input_source/input_source.py
+8
-4
tensorpack/train/interface.py
tensorpack/train/interface.py
+3
-3
tensorpack/trainv1/config.py
tensorpack/trainv1/config.py
+1
-1
tensorpack/trainv1/multigpu.py
tensorpack/trainv1/multigpu.py
+3
-3
No files found.
.github/ISSUE_TEMPLATE.md
View file @
9ecf87de
Bug Reports/Feature Requests/Usage Questions Only:
Bug Reports:
Bug Reports
(including performance bug)
:
Some part of code (either the library or examples) doesn't work as expected.
Always include what you did, what you observed, what you expected.
Feature Requests:
1.
Improve an existing feature.
2.
Add a new feature. Please note that, you can implement a lot of features by extending tensorpack
(See http://tensorpack.readthedocs.io/en/latest/tutorial/index.html#extend-tensorpack).
It may not have to be added to tensorpack unless you have a good reason.
3.
Note that we don't implement papers at other
's
requests.
3.
Note that we don't implement papers at other
s'
requests.
Usage Questions, e.g.:
"How do I do [this specific thing] in tensorpack?"
...
...
CHANGES.md
View file @
9ecf87de
...
...
@@ -10,10 +10,10 @@ TensorFlow itself also changed APIs before 1.0 and those are not listed here.
+
[2017/10/21]
tensorpack is gradually switching to a new Trainer API.
Compatibility is kept in most ways but not guaranteed
.
The old API will keep working for a while
.
To switch to new API, the easiest way is to:
1. `export TENSORPACK_TRAIN_API=v2` (will be default in the future).
1. `export TENSORPACK_TRAIN_API=v2` (will be default
soon
in the future).
2. Replace `SomeTrainer(config, ...).train()` with `launch_train_with_config(config, SomeTrainer(...))`.
+
[2017/10/18]
...
...
docs/conf.py
View file @
9ecf87de
...
...
@@ -367,6 +367,7 @@ def autodoc_skip_member(app, what, name, obj, skip, options):
'VisualQA'
,
'huber_loss'
,
'DumpTensor'
,
'StagingInputWrapper'
,
'StepTensorPrinter'
]:
return
True
...
...
docs/tutorial/trainer.md
View file @
9ecf87de
...
...
@@ -22,36 +22,31 @@ In other words, an "epoch" in tensorpack is the __default period to run callback
### Common Trainers
<!--
-Most neural network training tasks are single-cost optimization.
-Tensorpack provides some trainer implementations for such tasks.
-These trainers will build the graph based on the given
`ModelDesc`
, and minimizes
`ModelDesc.cost`
.
-->
<!--
-To use trainers, pass a
`TrainConfig`
to configure them:
-
-
```python
-config = TrainConfig(
- model=MyModel()
- dataflow=my_dataflow,
- # data=my_inputsource, # alternatively, use a customized InputSource
- callbacks=[...]
- )
-
-# start training:
-SomeTrainer(config, other_arguments).train()
-
-# start multi-GPU training with synchronous update:
-# SyncMultiGPUTrainerParameterServer(config).train()
-```
-
-When you set the DataFlow (rather than the InputSource) in the config,
-tensorpack trainers automatically adopt certain prefetch mechanism, as mentioned
-in the
[
Input Pipeline
](
input-source.html
)
tutorial.
-You can set the InputSource instead, to customize this behavior.
-->
Trainers are being redesigned, this page will be updated soon.
Most neural network training tasks are single-cost optimization.
Tensorpack provides some trainer implementations for such tasks.
These trainers will build the graph based on inputs and functions which build the cost from inputs.
The simplest way to use trainers, is to pass a
`TrainConfig`
to the
`launch_train_with_config`
high-level wrapper.
```
python
config
=
TrainConfig
(
model
=
MyModel
()
dataflow
=
my_dataflow
,
# data=my_inputsource, # alternatively, use a customized InputSource
callbacks
=
[
...
]
)
trainer
=
SomeTrainer
()
# multi-GPU training with synchronous update:
# trainer = SyncMultiGPUTrainerParameterServer([0, 1, 2])
launch_train_with_config
(
config
,
trainer
)
```
When you set the DataFlow (rather than the InputSource) in the config,
`launch_train_with_config`
automatically adopt certain prefetch mechanism, as mentioned
in the
[
Input Pipeline
](
input-source.html
)
tutorial.
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.
...
...
examples/GAN/GAN.py
View file @
9ecf87de
...
...
@@ -7,7 +7,7 @@ import tensorflow as tf
import
numpy
as
np
import
time
from
tensorpack
import
(
Trainer
,
QueueInput
,
ModelDescBase
,
DataFlow
,
StagingInput
Wrapper
,
ModelDescBase
,
DataFlow
,
StagingInput
,
TowerContext
)
from
tensorpack.graph_builder
import
DataParallelBuilder
,
LeastLoadedDeviceSetter
from
tensorpack.tfutils.summary
import
add_moving_summary
...
...
@@ -136,7 +136,7 @@ class MultiGPUGANTrainer(Trainer):
raw_devices
=
[
'/gpu:{}'
.
format
(
k
)
for
k
in
config
.
tower
]
# setup input
input
=
StagingInput
Wrapper
(
QueueInput
(
config
.
dataflow
),
config
.
tower
)
input
=
StagingInput
(
QueueInput
(
config
.
dataflow
),
config
.
tower
)
model
=
config
.
model
cbs
=
input
.
setup
(
model
.
get_inputs_desc
())
config
.
callbacks
.
extend
(
cbs
)
...
...
tensorpack/callbacks/inference_runner.py
View file @
9ecf87de
...
...
@@ -203,7 +203,7 @@ class DataParallelInferenceRunner(InferenceRunnerBase):
self
.
_input_callbacks
=
Callbacks
(
input_callbacks
)
# InputSource might have hooks which break us.
# e.g. hooks from StagingInput
Wrapper
will force the consumption
# e.g. hooks from StagingInput will force the consumption
# of nr_tower datapoints in every run.
input_hooks
=
self
.
_input_callbacks
.
get_hooks
()
self
.
_hooks
=
[
self
.
_build_hook
(
inf
)
for
inf
in
self
.
infs
]
+
input_hooks
...
...
tensorpack/input_source/input_source.py
View file @
9ecf87de
...
...
@@ -28,7 +28,8 @@ __all__ = ['PlaceholderInput', 'FeedInput',
'QueueInput'
,
'BatchQueueInput'
,
'DummyConstantInput'
,
'TensorInput'
,
'TFDatasetInput'
,
'StagingInputWrapper'
]
'StagingInputWrapper'
,
'StagingInput'
]
class
PlaceholderInput
(
InputSource
):
...
...
@@ -398,7 +399,7 @@ class TFDatasetInput(FeedfreeInput):
return
self
.
_iterator
.
get_next
()
class
StagingInput
Wrapper
(
FeedfreeInput
):
class
StagingInput
(
FeedfreeInput
):
"""
A wrapper around a feedfree input,
to prefetch the input in StagingArea (on GPUs).
...
...
@@ -433,7 +434,7 @@ class StagingInputWrapper(FeedfreeInput):
self
.
_input
=
input
if
not
isinstance
(
towers
[
0
],
int
):
# API changed
log_deprecated
(
"StagingInput
Wrapper
(devices=)"
,
"Use (towers=) instead!"
,
"2018-01-31"
)
log_deprecated
(
"StagingInput(devices=)"
,
"Use (towers=) instead!"
,
"2018-01-31"
)
self
.
_devices
=
towers
else
:
self
.
_devices
=
[
'/gpu:{}'
.
format
(
k
)
for
k
in
towers
]
...
...
@@ -451,7 +452,7 @@ class StagingInputWrapper(FeedfreeInput):
cbs
=
self
.
_input
.
get_callbacks
()
cbs
.
append
(
StagingInput
Wrapper
.
StagingCallback
(
StagingInput
.
StagingCallback
(
self
.
_get_stage_op
(),
self
.
_get_unstage_op
(),
self
.
_nr_stage
))
return
cbs
...
...
@@ -488,3 +489,6 @@ class StagingInputWrapper(FeedfreeInput):
with
self
.
cached_name_scope
():
all_outputs
=
list
(
chain
.
from_iterable
(
self
.
_unstage_ops
))
return
tf
.
group
(
*
all_outputs
)
StagingInputWrapper
=
StagingInput
tensorpack/train/interface.py
View file @
9ecf87de
...
...
@@ -5,7 +5,7 @@
import
tensorflow
as
tf
from
..input_source
import
(
InputSource
,
FeedInput
,
QueueInput
,
StagingInput
Wrapper
,
DummyConstantInput
)
InputSource
,
FeedInput
,
QueueInput
,
StagingInput
,
DummyConstantInput
)
from
..trainv1.config
import
TrainConfig
from
.base
import
SingleCostTrainer
...
...
@@ -36,8 +36,8 @@ def apply_default_prefetch(input_source_or_dataflow, trainer, towers):
assert
not
isinstance
(
trainer
,
SimpleTrainer
)
assert
tf
.
test
.
is_gpu_available
()
if
not
isinstance
(
input
,
(
StagingInput
Wrapper
,
DummyConstantInput
)):
input
=
StagingInput
Wrapper
(
input
,
towers
)
if
not
isinstance
(
input
,
(
StagingInput
,
DummyConstantInput
)):
input
=
StagingInput
(
input
,
towers
)
return
input
...
...
tensorpack/trainv1/config.py
View file @
9ecf87de
...
...
@@ -19,7 +19,7 @@ __all__ = ['TrainConfig']
class
TrainConfig
(
object
):
"""
Config for trainer
.
A collection of options to be used for trainers
.
"""
def
__init__
(
self
,
...
...
tensorpack/trainv1/multigpu.py
View file @
9ecf87de
...
...
@@ -8,7 +8,7 @@ import tensorflow as tf
from
..callbacks.graph
import
RunOp
from
..utils.develop
import
log_deprecated
from
..input_source
import
QueueInput
,
StagingInput
Wrapper
,
DummyConstantInput
from
..input_source
import
QueueInput
,
StagingInput
,
DummyConstantInput
from
..graph_builder.training
import
(
SyncMultiGPUParameterServerBuilder
,
SyncMultiGPUReplicatedBuilder
,
...
...
@@ -43,8 +43,8 @@ def apply_prefetch_policy(config, gpu_prefetch=True):
assert
tf
.
test
.
is_gpu_available
()
# seem to only improve on >1 GPUs
if
not
isinstance
(
config
.
data
,
(
StagingInput
Wrapper
,
DummyConstantInput
)):
config
.
data
=
StagingInput
Wrapper
(
config
.
data
,
config
.
tower
)
if
not
isinstance
(
config
.
data
,
(
StagingInput
,
DummyConstantInput
)):
config
.
data
=
StagingInput
(
config
.
data
,
config
.
tower
)
class
SyncMultiGPUTrainerParameterServer
(
Trainer
):
...
...
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