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

Method _setup_graph

tensorpack/train/trainers.py:465–477  ·  view source on GitHub ↗
(self, input, get_cost_fn, get_opt_fn)

Source from the content-addressed store, hash-verified

463 return averaged_gradients
464
465 def _setup_graph(self, input, get_cost_fn, get_opt_fn):
466 with TrainTowerContext(''):
467 grads = self._make_get_grad_fn(input, get_cost_fn, get_opt_fn)()
468 grads = self.allreduce(grads)
469
470 opt = get_opt_fn()
471 self.train_op = opt.apply_gradients(grads, name='train_op')
472
473 cb = CallbackFactory(
474 before_train=self.broadcast,
475 trigger=self.broadcast if self.BROADCAST_EVERY_EPOCH else None
476 ).set_chief_only(False)
477 return [cb]
478
479 def broadcast(self, _):
480 logger.info("Broadcasting {} global variables ...".format(self._num_global_variables))

Callers

nothing calls this directly

Calls 6

allreduceMethod · 0.95
TrainTowerContextClass · 0.85
CallbackFactoryClass · 0.85
_make_get_grad_fnMethod · 0.80
set_chief_onlyMethod · 0.80
apply_gradientsMethod · 0.45

Tested by

no test coverage detected