MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / minimize

Method minimize

tensorflow/contrib/optimizer_v2/optimizer_v2.py:654–724  ·  view source on GitHub ↗

Add operations to minimize `loss` by updating `var_list`. This method simply combines calls `compute_gradients()` and `apply_gradients()`. If you want to process the gradient before applying them call `compute_gradients()` and `apply_gradients()` explicitly instead of using this fun

(self,
               loss,
               global_step=None,
               var_list=None,
               gate_gradients=GATE_OP,
               aggregation_method=None,
               name=None,
               grad_loss=None,
               stop_gradients=None,
               scale_loss_by_num_replicas=False)

Source from the content-addressed store, hash-verified

652 self._hyper[name] = (_is_dynamic(value), value)
653
654 def minimize(self,
655 loss,
656 global_step=None,
657 var_list=None,
658 gate_gradients=GATE_OP,
659 aggregation_method=None,
660 name=None,
661 grad_loss=None,
662 stop_gradients=None,
663 scale_loss_by_num_replicas=False):
664 """Add operations to minimize `loss` by updating `var_list`.
665
666 This method simply combines calls `compute_gradients()` and
667 `apply_gradients()`. If you want to process the gradient before applying
668 them call `compute_gradients()` and `apply_gradients()` explicitly instead
669 of using this function.
670
671 Args:
672 loss: A `Tensor` containing the value to minimize.
673 global_step: Optional `Variable` to increment by one after the variables
674 have been updated.
675 var_list: Optional list or tuple of `Variable` objects to update to
676 minimize `loss`. Defaults to the list of variables collected in the
677 graph under the key `GraphKeys.TRAINABLE_VARIABLES`.
678 gate_gradients: How to gate the computation of gradients. Can be
679 `GATE_NONE`, `GATE_OP`, or `GATE_GRAPH`.
680 aggregation_method: Specifies the method used to combine gradient terms.
681 Valid values are defined in the class `AggregationMethod`.
682 name: Optional name for the returned operation.
683 grad_loss: Optional. A `Tensor` holding the gradient computed for `loss`.
684 stop_gradients: Optional. A Tensor or list of tensors not to differentiate
685 through.
686 scale_loss_by_num_replicas: Optional boolean. If true, scale the loss down
687 by the number of replicas. DEPRECATED and generally no longer needed.
688
689 Returns:
690 An Operation that updates the variables in `var_list`. If `global_step`
691 was not `None`, that operation also increments `global_step`.
692
693 Raises:
694 ValueError: If some of the variables are not `Variable` objects.
695
696 @compatibility(eager)
697 When eager execution is enabled, `loss` should be a Python function that
698 takes elements of `var_list` as arguments and computes the value to be
699 minimized. If `var_list` is None, `loss` should take no arguments.
700 Minimization (and gradient computation) is done with respect to the
701 elements of `var_list` if not None, else with respect to any trainable
702 variables created during the execution of the `loss` function.
703 `gate_gradients`, `aggregation_method`, and `grad_loss` are ignored when
704 eager execution is enabled.
705 @end_compatibility
706 """
707 grads_and_vars = self.compute_gradients(
708 loss,
709 var_list=var_list,
710 gate_gradients=gate_gradients,
711 aggregation_method=aggregation_method,

Callers 15

_create_graphMethod · 0.45
train_one_epochFunction · 0.45
benchmark_graph_trainMethod · 0.45
testTrainWithSummaryMethod · 0.45
benchmark_graph_trainMethod · 0.45
training_graphMethod · 0.45
_TestTrainingOpsCheckMethod · 0.45
model_fnMethod · 0.45
model_fnFunction · 0.45

Calls 2

compute_gradientsMethod · 0.95
apply_gradientsMethod · 0.95

Tested by 15

_create_graphMethod · 0.36
benchmark_graph_trainMethod · 0.36
testTrainWithSummaryMethod · 0.36
benchmark_graph_trainMethod · 0.36
_TestTrainingOpsCheckMethod · 0.36
model_fnMethod · 0.36
testSlotsUniqueEagerMethod · 0.36
testBasicMethod · 0.36