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
Hide 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/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.
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:
Feature Requests:
1.
Improve an existing feature.
1.
Improve an existing feature.
2.
Add a new feature. Please note that, you can implement a lot of features by extending tensorpack
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).
(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.
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.:
Usage Questions, e.g.:
"How do I do [this specific thing] in tensorpack?"
"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.
...
@@ -10,10 +10,10 @@ TensorFlow itself also changed APIs before 1.0 and those are not listed here.
+
[2017/10/21]
+
[2017/10/21]
tensorpack is gradually switching to a new Trainer API.
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:
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(...))`.
2. Replace `SomeTrainer(config, ...).train()` with `launch_train_with_config(config, SomeTrainer(...))`.
+
[2017/10/18]
+
[2017/10/18]
...
...
docs/conf.py
View file @
9ecf87de
...
@@ -367,6 +367,7 @@ def autodoc_skip_member(app, what, name, obj, skip, options):
...
@@ -367,6 +367,7 @@ def autodoc_skip_member(app, what, name, obj, skip, options):
'VisualQA'
,
'VisualQA'
,
'huber_loss'
,
'huber_loss'
,
'DumpTensor'
,
'DumpTensor'
,
'StagingInputWrapper'
,
'StepTensorPrinter'
'StepTensorPrinter'
]:
]:
return
True
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
...
@@ -22,36 +22,31 @@ In other words, an "epoch" in tensorpack is the __default period to run callback
### Common Trainers
### 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 inputs and functions which build the cost from inputs.
-These trainers will build the graph based on the given
`ModelDesc`
, and minimizes
`ModelDesc.cost`
.
-->
The simplest way to use trainers, is to pass a
`TrainConfig`
to the
`launch_train_with_config`
high-level wrapper.
<!--
-To use trainers, pass a
`TrainConfig`
to configure them:
```
python
-
config
=
TrainConfig
(
-
```python
model
=
MyModel
()
-config = TrainConfig(
dataflow
=
my_dataflow
,
- model=MyModel()
# data=my_inputsource, # alternatively, use a customized InputSource
- dataflow=my_dataflow,
callbacks
=
[
...
]
- # data=my_inputsource, # alternatively, use a customized InputSource
)
- callbacks=[...]
- )
trainer
=
SomeTrainer
()
-
# multi-GPU training with synchronous update:
-# start training:
# trainer = SyncMultiGPUTrainerParameterServer([0, 1, 2])
-SomeTrainer(config, other_arguments).train()
launch_train_with_config
(
config
,
trainer
)
-
```
-# start multi-GPU training with synchronous update:
-# SyncMultiGPUTrainerParameterServer(config).train()
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.
-When you set the DataFlow (rather than the InputSource) in the config,
You can set the InputSource instead, to customize this behavior.
-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.
Existing multi-GPU trainers include the logic of data-parallel training.
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.
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
...
@@ -7,7 +7,7 @@ import tensorflow as tf
import
numpy
as
np
import
numpy
as
np
import
time
import
time
from
tensorpack
import
(
Trainer
,
QueueInput
,
from
tensorpack
import
(
Trainer
,
QueueInput
,
ModelDescBase
,
DataFlow
,
StagingInput
Wrapper
,
ModelDescBase
,
DataFlow
,
StagingInput
,
TowerContext
)
TowerContext
)
from
tensorpack.graph_builder
import
DataParallelBuilder
,
LeastLoadedDeviceSetter
from
tensorpack.graph_builder
import
DataParallelBuilder
,
LeastLoadedDeviceSetter
from
tensorpack.tfutils.summary
import
add_moving_summary
from
tensorpack.tfutils.summary
import
add_moving_summary
...
@@ -136,7 +136,7 @@ class MultiGPUGANTrainer(Trainer):
...
@@ -136,7 +136,7 @@ class MultiGPUGANTrainer(Trainer):
raw_devices
=
[
'/gpu:{}'
.
format
(
k
)
for
k
in
config
.
tower
]
raw_devices
=
[
'/gpu:{}'
.
format
(
k
)
for
k
in
config
.
tower
]
# setup input
# setup input
input
=
StagingInput
Wrapper
(
QueueInput
(
config
.
dataflow
),
config
.
tower
)
input
=
StagingInput
(
QueueInput
(
config
.
dataflow
),
config
.
tower
)
model
=
config
.
model
model
=
config
.
model
cbs
=
input
.
setup
(
model
.
get_inputs_desc
())
cbs
=
input
.
setup
(
model
.
get_inputs_desc
())
config
.
callbacks
.
extend
(
cbs
)
config
.
callbacks
.
extend
(
cbs
)
...
...
tensorpack/callbacks/inference_runner.py
View file @
9ecf87de
...
@@ -203,7 +203,7 @@ class DataParallelInferenceRunner(InferenceRunnerBase):
...
@@ -203,7 +203,7 @@ class DataParallelInferenceRunner(InferenceRunnerBase):
self
.
_input_callbacks
=
Callbacks
(
input_callbacks
)
self
.
_input_callbacks
=
Callbacks
(
input_callbacks
)
# InputSource might have hooks which break us.
# 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.
# of nr_tower datapoints in every run.
input_hooks
=
self
.
_input_callbacks
.
get_hooks
()
input_hooks
=
self
.
_input_callbacks
.
get_hooks
()
self
.
_hooks
=
[
self
.
_build_hook
(
inf
)
for
inf
in
self
.
infs
]
+
input_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',
...
@@ -28,7 +28,8 @@ __all__ = ['PlaceholderInput', 'FeedInput',
'QueueInput'
,
'BatchQueueInput'
,
'QueueInput'
,
'BatchQueueInput'
,
'DummyConstantInput'
,
'TensorInput'
,
'DummyConstantInput'
,
'TensorInput'
,
'TFDatasetInput'
,
'TFDatasetInput'
,
'StagingInputWrapper'
]
'StagingInputWrapper'
,
'StagingInput'
]
class
PlaceholderInput
(
InputSource
):
class
PlaceholderInput
(
InputSource
):
...
@@ -398,7 +399,7 @@ class TFDatasetInput(FeedfreeInput):
...
@@ -398,7 +399,7 @@ class TFDatasetInput(FeedfreeInput):
return
self
.
_iterator
.
get_next
()
return
self
.
_iterator
.
get_next
()
class
StagingInput
Wrapper
(
FeedfreeInput
):
class
StagingInput
(
FeedfreeInput
):
"""
"""
A wrapper around a feedfree input,
A wrapper around a feedfree input,
to prefetch the input in StagingArea (on GPUs).
to prefetch the input in StagingArea (on GPUs).
...
@@ -433,7 +434,7 @@ class StagingInputWrapper(FeedfreeInput):
...
@@ -433,7 +434,7 @@ class StagingInputWrapper(FeedfreeInput):
self
.
_input
=
input
self
.
_input
=
input
if
not
isinstance
(
towers
[
0
],
int
):
if
not
isinstance
(
towers
[
0
],
int
):
# API changed
# 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
self
.
_devices
=
towers
else
:
else
:
self
.
_devices
=
[
'/gpu:{}'
.
format
(
k
)
for
k
in
towers
]
self
.
_devices
=
[
'/gpu:{}'
.
format
(
k
)
for
k
in
towers
]
...
@@ -451,7 +452,7 @@ class StagingInputWrapper(FeedfreeInput):
...
@@ -451,7 +452,7 @@ class StagingInputWrapper(FeedfreeInput):
cbs
=
self
.
_input
.
get_callbacks
()
cbs
=
self
.
_input
.
get_callbacks
()
cbs
.
append
(
cbs
.
append
(
StagingInput
Wrapper
.
StagingCallback
(
StagingInput
.
StagingCallback
(
self
.
_get_stage_op
(),
self
.
_get_unstage_op
(),
self
.
_nr_stage
))
self
.
_get_stage_op
(),
self
.
_get_unstage_op
(),
self
.
_nr_stage
))
return
cbs
return
cbs
...
@@ -488,3 +489,6 @@ class StagingInputWrapper(FeedfreeInput):
...
@@ -488,3 +489,6 @@ class StagingInputWrapper(FeedfreeInput):
with
self
.
cached_name_scope
():
with
self
.
cached_name_scope
():
all_outputs
=
list
(
chain
.
from_iterable
(
self
.
_unstage_ops
))
all_outputs
=
list
(
chain
.
from_iterable
(
self
.
_unstage_ops
))
return
tf
.
group
(
*
all_outputs
)
return
tf
.
group
(
*
all_outputs
)
StagingInputWrapper
=
StagingInput
tensorpack/train/interface.py
View file @
9ecf87de
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
import
tensorflow
as
tf
import
tensorflow
as
tf
from
..input_source
import
(
from
..input_source
import
(
InputSource
,
FeedInput
,
QueueInput
,
StagingInput
Wrapper
,
DummyConstantInput
)
InputSource
,
FeedInput
,
QueueInput
,
StagingInput
,
DummyConstantInput
)
from
..trainv1.config
import
TrainConfig
from
..trainv1.config
import
TrainConfig
from
.base
import
SingleCostTrainer
from
.base
import
SingleCostTrainer
...
@@ -36,8 +36,8 @@ def apply_default_prefetch(input_source_or_dataflow, trainer, towers):
...
@@ -36,8 +36,8 @@ def apply_default_prefetch(input_source_or_dataflow, trainer, towers):
assert
not
isinstance
(
trainer
,
SimpleTrainer
)
assert
not
isinstance
(
trainer
,
SimpleTrainer
)
assert
tf
.
test
.
is_gpu_available
()
assert
tf
.
test
.
is_gpu_available
()
if
not
isinstance
(
input
,
(
StagingInput
Wrapper
,
DummyConstantInput
)):
if
not
isinstance
(
input
,
(
StagingInput
,
DummyConstantInput
)):
input
=
StagingInput
Wrapper
(
input
,
towers
)
input
=
StagingInput
(
input
,
towers
)
return
input
return
input
...
...
tensorpack/trainv1/config.py
View file @
9ecf87de
...
@@ -19,7 +19,7 @@ __all__ = ['TrainConfig']
...
@@ -19,7 +19,7 @@ __all__ = ['TrainConfig']
class
TrainConfig
(
object
):
class
TrainConfig
(
object
):
"""
"""
Config for trainer
.
A collection of options to be used for trainers
.
"""
"""
def
__init__
(
self
,
def
__init__
(
self
,
...
...
tensorpack/trainv1/multigpu.py
View file @
9ecf87de
...
@@ -8,7 +8,7 @@ import tensorflow as tf
...
@@ -8,7 +8,7 @@ import tensorflow as tf
from
..callbacks.graph
import
RunOp
from
..callbacks.graph
import
RunOp
from
..utils.develop
import
log_deprecated
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
(
from
..graph_builder.training
import
(
SyncMultiGPUParameterServerBuilder
,
SyncMultiGPUParameterServerBuilder
,
SyncMultiGPUReplicatedBuilder
,
SyncMultiGPUReplicatedBuilder
,
...
@@ -43,8 +43,8 @@ def apply_prefetch_policy(config, gpu_prefetch=True):
...
@@ -43,8 +43,8 @@ def apply_prefetch_policy(config, gpu_prefetch=True):
assert
tf
.
test
.
is_gpu_available
()
assert
tf
.
test
.
is_gpu_available
()
# seem to only improve on >1 GPUs
# seem to only improve on >1 GPUs
if
not
isinstance
(
config
.
data
,
(
StagingInput
Wrapper
,
DummyConstantInput
)):
if
not
isinstance
(
config
.
data
,
(
StagingInput
,
DummyConstantInput
)):
config
.
data
=
StagingInput
Wrapper
(
config
.
data
,
config
.
tower
)
config
.
data
=
StagingInput
(
config
.
data
,
config
.
tower
)
class
SyncMultiGPUTrainerParameterServer
(
Trainer
):
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