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

Method __init__

tensorpack/predict/feedfree.py:19–48  ·  view source on GitHub ↗

Args: config (PredictConfig): the config to use. input_source (InputSource): the feedfree InputSource to use. Must match the signature of the tower function in config.

(self, config, input_source)

Source from the content-addressed store, hash-verified

17 """
18
19 def __init__(self, config, input_source):
20 """
21 Args:
22 config (PredictConfig): the config to use.
23 input_source (InputSource): the feedfree InputSource to use.
24 Must match the signature of the tower function in config.
25 """
26 self._config = config
27 self._input_source = input_source
28 assert config.return_input is False, \
29 "return_input is not supported in FeedfreePredictor! " \
30 "If you need to fetch inputs, add the names to the output_names!"
31
32 self._hooks = []
33 self.graph = config._maybe_create_graph()
34 with self.graph.as_default():
35 self._input_callbacks = Callbacks(
36 self._input_source.setup(config.input_signature))
37 with PredictTowerContext(''):
38 self._input_tensors = self._input_source.get_input_tensors()
39 config.tower_func(*self._input_tensors)
40 self._tower_handle = config.tower_func.towers[-1]
41
42 self._output_tensors = self._tower_handle.get_tensors(config.output_names)
43
44 self._input_callbacks.setup_graph(None)
45
46 for h in self._input_callbacks.get_hooks():
47 self._register_hook(h)
48 self._initialize_session()
49
50 def _register_hook(self, hook):
51 """

Callers

nothing calls this directly

Calls 11

_register_hookMethod · 0.95
_initialize_sessionMethod · 0.95
CallbacksClass · 0.85
PredictTowerContextClass · 0.85
_maybe_create_graphMethod · 0.80
setupMethod · 0.80
get_input_tensorsMethod · 0.80
tower_funcMethod · 0.80
get_tensorsMethod · 0.80
get_hooksMethod · 0.80
setup_graphMethod · 0.45

Tested by

no test coverage detected