MCPcopy Index your code
hub / github.com/tensorpack/tensorpack / __init__

Method __init__

tensorpack/callbacks/inference_runner.py:108–132  ·  view source on GitHub ↗

Args: input (InputSource or DataFlow): The :class:`InputSource` to run inference on. If given a DataFlow, will use :class:`FeedInput`. infs (list): a list of :class:`Inferencer` instances. tower_name (str): the name scope of the tower to

(self, input, infs, tower_name='InferenceTower', tower_func=None, device=0)

Source from the content-addressed store, hash-verified

106 """
107
108 def __init__(self, input, infs, tower_name='InferenceTower', tower_func=None, device=0):
109 """
110 Args:
111 input (InputSource or DataFlow): The :class:`InputSource` to run
112 inference on. If given a DataFlow, will use :class:`FeedInput`.
113 infs (list): a list of :class:`Inferencer` instances.
114 tower_name (str): the name scope of the tower to build.
115 If multiple InferenceRunner are used, each needs a different tower_name.
116 tower_func (tfutils.TowerFunc or None): the tower function to be used to build the graph.
117 By defaults to call `trainer.tower_func` under a `training=False` TowerContext,
118 but you can change it to a different tower function
119 if you need to inference with several different graphs.
120 device (int): the device to use
121 """
122 if isinstance(input, DataFlow):
123 # use infinite=False so that a dataflow without size will stop normally
124 # TODO a better way to handle inference size
125 input = FeedInput(input, infinite=False)
126 assert isinstance(input, InputSource), input
127 assert not isinstance(input, StagingInput), input
128 self._tower_name = tower_name
129 self._device_id = device
130 self._device = _device_from_int(device)
131 self._tower_func = tower_func
132 super(InferenceRunner, self).__init__(input, infs)
133
134 def _build_hook(self, inf):
135 out_names = inf.get_fetches()

Callers 2

__init__Method · 0.45
__init__Method · 0.45

Calls 2

FeedInputClass · 0.85
_device_from_intFunction · 0.85

Tested by

no test coverage detected