Skip to content

Commit

Permalink
update docs formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ppwwyyxx committed Jan 13, 2020
1 parent 8cfcc47 commit b88a40a
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions docs/tutorial/inference.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ There are two ways to do inference during training.

1. The easiest way is to write a callback, and use
[self.trainer.get_predictor()](../modules/train.html#tensorpack.train.TowerTrainer.get_predictor)
to get a callable under inference mode.
See [Write a Callback](extend/callback.html).
to get a callable under inference mode.
See [Write a Callback](extend/callback.html).

2. If your inference follows the paradigm of:
"evaluate some tensors for each input, and aggregate the results in the end".
You can use the `InferenceRunner` interface with some `Inferencer`.
This will further support prefetch & data-parallel inference.
"evaluate some tensors for each input, and aggregate the results in the end".
You can use the `InferenceRunner` interface with some `Inferencer`.
This will further support prefetch & data-parallel inference.

Currently this lacks documentation, but you can refer to examples
that uses `InferenceRunner` or custom `Inferencer` to learn more.
Expand Down Expand Up @@ -133,29 +133,29 @@ tensorpack's `ModelDesc`, you can also build it like this:
a, b = tf.placeholder(...), tf.placeholder(...)
# call ANY symbolic functions on a, b. e.g.:
with TowerContext('', is_training=False):
model.build_graph(a, b)
model.build_graph(a, b)
```

```eval_rst
.. 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".
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).
Therefore it is usually wrong to import a training metagraph for inference.
Metagraph is the wrong abstraction for a "model".
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).
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.
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.
It's also very common to change the graph for 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
the training graph). However metagraph is not designed to be easily modified at all.
It's also very common to change the graph for 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
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
Expand Down

0 comments on commit b88a40a

Please sign in to comment.