Commit 27957082 authored by Yuxin Wu's avatar Yuxin Wu

docs update

parent c94585b4
...@@ -363,6 +363,7 @@ def autodoc_skip_member(app, what, name, obj, skip, options): ...@@ -363,6 +363,7 @@ def autodoc_skip_member(app, what, name, obj, skip, options):
'predictor_factory', 'predictor_factory',
'get_predictors', 'get_predictors',
'vs_name_for_predictor', 'vs_name_for_predictor',
'RandomCropAroundBox',
'dump_chkpt_vars', 'dump_chkpt_vars',
'VisualQA', 'VisualQA',
'ParamRestore']: 'ParamRestore']:
......
...@@ -32,19 +32,20 @@ the argument `inputs` is the list of input tensors matching `_get_inputs`. ...@@ -32,19 +32,20 @@ the argument `inputs` is the list of input tensors matching `_get_inputs`.
You can use any symbolic functions in `_build_graph`, including TensorFlow core library You can use any symbolic functions in `_build_graph`, including TensorFlow core library
functions and other symbolic libraries. functions and other symbolic libraries.
### How is it Used: ### How it is Used:
Most tensorpack trainers expect a `ModelDesc`, and use it as a __description Most tensorpack trainers expect a `ModelDesc`, and use it as a __description
of the TF graph__ (except for the input pipeline). of the TF graph to be built__.
These trainers will use `_get_inputs` to connect the given `InputSource` to the graph. These trainers will use `_get_inputs` to connect the given `InputSource` to the graph.
They'll then use `_build_graph` to create the backbone model, and then `_get_optimizer` to create the minimization op, and run it. They'll then use `_build_graph` to create the backbone model, and then `_get_optimizer` to create the minimization op, and run it.
Note that data-parallel multi-GPU trainers will call `_build_graph` __multiple times__ on each GPU. Note that data-parallel multi-GPU trainers will call `_build_graph` __multiple times__ on each GPU.
A trainer may also make __extra calls__ to `_build_graph` for inference, if used by some callbacks. A trainer may also make __extra calls__ to `_build_graph` for inference, if used by some callbacks.
`_build_graph` will always be called under some `TowerContext` which contains these information `_build_graph` will always be called under some `TowerContext` which contains these context information
(e.g. training or inference, reuse or not, scope name) for your access. (e.g. training or inference, reuse or not, scope name) for your access.
Also, to respect variable reuse among multiple calls, use `tf.get_variable()` instead of `tf.Variable`. Also, to respect variable reuse among multiple calls, use `tf.get_variable()` instead of `tf.Variable` in `_build_graph`,
if you need to create and variables.
### Build It Manually ### Build It Manually
......
...@@ -9,8 +9,7 @@ from ...utils.argtools import shape2d ...@@ -9,8 +9,7 @@ from ...utils.argtools import shape2d
from six.moves import range from six.moves import range
import numpy as np import numpy as np
__all__ = ['RandomCrop', 'CenterCrop', __all__ = ['RandomCrop', 'CenterCrop', 'RandomCropAroundBox', 'RandomCropRandomShape']
'perturb_BB', 'RandomCropAroundBox', 'RandomCropRandomShape']
class RandomCrop(ImageAugmentor): class RandomCrop(ImageAugmentor):
...@@ -111,9 +110,10 @@ def perturb_BB(image_shape, bb, max_perturb_pixel, ...@@ -111,9 +110,10 @@ def perturb_BB(image_shape, bb, max_perturb_pixel,
return bb return bb
# TODO shouldn't include strange augmentors like this.
class RandomCropAroundBox(ImageAugmentor): class RandomCropAroundBox(ImageAugmentor):
""" """
Crop a box around a bounding box by some random perturbation Crop a box around a bounding box by some random perturbation.
""" """
def __init__(self, perturb_ratio, max_aspect_ratio_diff=0.3): def __init__(self, perturb_ratio, max_aspect_ratio_diff=0.3):
......
...@@ -150,7 +150,7 @@ class PrefetchDataZMQ(ProxyDataFlow): ...@@ -150,7 +150,7 @@ class PrefetchDataZMQ(ProxyDataFlow):
nr_proc (int): number of processes to use. nr_proc (int): number of processes to use.
hwm (int): the zmq "high-water mark" for both sender and receiver. hwm (int): the zmq "high-water mark" for both sender and receiver.
""" """
assert os.name != 'nt', "PrefetchDataZMQ doesn't support windows! Consider PrefetchData instead." assert os.name != 'nt', "PrefetchDataZMQ doesn't support windows! PrefetchData might work sometimes."
super(PrefetchDataZMQ, self).__init__(ds) super(PrefetchDataZMQ, self).__init__(ds)
try: try:
self._size = ds.size() self._size = ds.size()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment