(self, loss, params)
| 728 | return self.optimizer.compute_gradients(loss, params) |
| 729 | |
| 730 | def get_updates(self, loss, params): |
| 731 | if distribution_strategy_context.has_strategy(): |
| 732 | self.updates = [] |
| 733 | |
| 734 | if not params: |
| 735 | # After the model vars have been created, the second call to get_updates |
| 736 | # is called with params as an empty list. This ensures that we call |
| 737 | # compute_gradients with params=None. |
| 738 | grads = self.optimizer.compute_gradients(loss) |
| 739 | else: |
| 740 | grads = self.optimizer.compute_gradients(loss, params) |
| 741 | global_step = training_util.get_global_step() |
| 742 | opt_update = self.optimizer.apply_gradients(grads, global_step) |
| 743 | else: |
| 744 | if not params: |
| 745 | self.updates = [state_ops.assign_add(self.iterations, 1)] |
| 746 | return self.updates |
| 747 | |
| 748 | # Updates list starts out empty because the iterations variable is |
| 749 | # incremented in optimizer.apply_gradients() |
| 750 | self.updates = [] |
| 751 | grads = self.optimizer.compute_gradients(loss, params) |
| 752 | opt_update = self.optimizer.apply_gradients( |
| 753 | grads, global_step=self.iterations) |
| 754 | |
| 755 | self.updates.append(opt_update) |
| 756 | return self.updates |
| 757 | |
| 758 | @property |
| 759 | def weights(self): |
nothing calls this directly
no test coverage detected