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

Method setup_graph

tensorpack/train/tower.py:197–220  ·  view source on GitHub ↗

Responsible for building the main training graph for single-cost training. Args: input_signature ([TensorSpec]): list of TensorSpec that describe the inputs input (InputSource): an InputSource which has to match the input signature get_cost_fn ([

(self, input_signature, input, get_cost_fn, get_opt_fn)

Source from the content-addressed store, hash-verified

195
196 @call_only_once
197 def setup_graph(self, input_signature, input, get_cost_fn, get_opt_fn):
198 """
199 Responsible for building the main training graph for single-cost training.
200
201 Args:
202 input_signature ([TensorSpec]): list of TensorSpec that describe the inputs
203 input (InputSource): an InputSource which has to match the input signature
204 get_cost_fn ([tf.Tensor] -> tf.Tensor): callable, takes some input tensors and return a cost tensor.
205 get_opt_fn (-> tf.train.Optimizer): callable which returns an
206 optimizer. Will only be called once.
207
208 Note:
209 `get_cost_fn` will be part of the tower function.
210 It must follows the `rules of tower function.
211 <http://tensorpack.readthedocs.io/tutorial/trainer.html#tower-trainer>`_.
212 """
213 get_cost_fn = TowerFunc(get_cost_fn, input_signature)
214 get_opt_fn = memoized(get_opt_fn)
215 self.tower_func = get_cost_fn
216
217 # TODO setup may want to register monitor as well??
218 input_callbacks = self._setup_input(input_signature, input)
219 train_callbacks = self._setup_graph(input, get_cost_fn, get_opt_fn)
220 self.register_callback(input_callbacks + train_callbacks)
221
222 @abstractmethod
223 def _setup_graph(self, input, get_cost_fn, get_opt_fn):

Callers 2

setup_callbacksMethod · 0.45
launch_train_with_configFunction · 0.45

Calls 3

_setup_inputMethod · 0.95
_setup_graphMethod · 0.95
TowerFuncClass · 0.85

Tested by

no test coverage detected