(self, input, get_cost_fn, get_opt_fn)
| 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)) |
nothing calls this directly
no test coverage detected