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
b88a40aa
Commit
b88a40aa
authored
Jan 13, 2020
by
Yuxin Wu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update docs formatting
parent
8cfcc47b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
16 deletions
+16
-16
docs/tutorial/inference.md
docs/tutorial/inference.md
+16
-16
No files found.
docs/tutorial/inference.md
View file @
b88a40aa
...
@@ -7,13 +7,13 @@ There are two ways to do inference during training.
...
@@ -7,13 +7,13 @@ There are two ways to do inference during training.
1.
The easiest way is to write a callback, and use
1.
The easiest way is to write a callback, and use
[
self.trainer.get_predictor()
](
../modules/train.html#tensorpack.train.TowerTrainer.get_predictor
)
[
self.trainer.get_predictor()
](
../modules/train.html#tensorpack.train.TowerTrainer.get_predictor
)
to get a callable under inference mode.
to get a callable under inference mode.
See
[
Write a Callback
](
extend/callback.html
)
.
See
[
Write a Callback
](
extend/callback.html
)
.
2.
If your inference follows the paradigm of:
2.
If your inference follows the paradigm of:
"evaluate some tensors for each input, and aggregate the results in the end".
"evaluate some tensors for each input, and aggregate the results in the end".
You can use the
`InferenceRunner`
interface with some
`Inferencer`
.
You can use the
`InferenceRunner`
interface with some
`Inferencer`
.
This will further support prefetch & data-parallel inference.
This will further support prefetch & data-parallel inference.
Currently this lacks documentation, but you can refer to examples
Currently this lacks documentation, but you can refer to examples
that uses `InferenceRunner` or custom `Inferencer` to learn more.
that uses `InferenceRunner` or custom `Inferencer` to learn more.
...
@@ -133,29 +133,29 @@ tensorpack's `ModelDesc`, you can also build it like this:
...
@@ -133,29 +133,29 @@ tensorpack's `ModelDesc`, you can also build it like this:
a
,
b
=
tf
.
placeholder
(
...
),
tf
.
placeholder
(
...
)
a
,
b
=
tf
.
placeholder
(
...
),
tf
.
placeholder
(
...
)
# call ANY symbolic functions on a, b. e.g.:
# call ANY symbolic functions on a, b. e.g.:
with
TowerContext
(
''
,
is_training
=
False
):
with
TowerContext
(
''
,
is_training
=
False
):
model
.
build_graph
(
a
,
b
)
model
.
build_graph
(
a
,
b
)
```
```
```
eval_rst
```
eval_rst
.. note:: **Do not use metagraph for inference!**
.. note:: **Do not use metagraph for inference!**
Tensorpack saves a metagraph during training. Users should not try to load it for inference.
Tensorpack saves a metagraph during training. Users should not try to load it for inference.
Metagraph is the wrong abstraction for a "model".
Metagraph is the wrong abstraction for a "model".
It stores the entire graph which contains not only the mathematical model, but also all the
It stores the entire graph which contains not only the mathematical model, but also all the
training settings (queues, iterators, summaries, evaluations, multi-gpu replications).
training settings (queues, iterators, summaries, evaluations, multi-gpu replications).
Therefore it is usually wrong to import a training metagraph for inference.
Therefore it is usually wrong to import a training metagraph for inference.
It's especially error-prone to load a metagraph on top of a non-empty graph.
It's especially error-prone to load a metagraph on top of a non-empty graph.
The potential name conflicts between the current graph and the nodes in the
The potential name conflicts between the current graph and the nodes in the
metagraph can lead to esoteric bugs or sometimes completely ruin the model.
metagraph can lead to esoteric bugs or sometimes completely ruin the model.
It's also very common to change the graph for inference.
It's also very common to change the graph for inference.
For example, you may need a different data layout for CPU inference,
For example, you may need a different data layout for CPU inference,
or you may need placeholders in the inference graph (which may not even exist in
or you may need placeholders in the inference graph (which may not even exist in
the training graph). However metagraph is not designed to be easily modified at all.
the training graph). However metagraph is not designed to be easily modified at all.
Due to the above reasons, to do inference, it's best to recreate a clean graph (and save it if needed) by yourself.
Due to the above reasons, to do inference, it's best to recreate a clean graph (and save it if needed) by yourself.
```
```
### Step 2: load the checkpoint
### Step 2: load the checkpoint
...
...
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