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

Method update

tensorflow/python/training/optimizer.py:784–810  ·  view source on GitHub ↗

Apply gradients to a replica variable.

(v, g)

Source from the content-addressed store, hash-verified

782 self._create_slots(var_list)
783
784 def update(v, g):
785 """Apply gradients to a replica variable."""
786 assert v is not None
787
788 try:
789 # Convert the grad to Tensor or IndexedSlices if necessary.
790 g = ops.convert_to_tensor_or_indexed_slices(g)
791 except TypeError:
792 raise TypeError("Gradient must be convertible to a Tensor"
793 " or IndexedSlices, or None: %s" % g)
794 if not isinstance(g, (ops.Tensor, ops.IndexedSlices)):
795 raise TypeError(
796 "Gradient must be a Tensor, IndexedSlices, or None: %s" % g)
797 p = _get_processor(v)
798
799 if context.executing_eagerly() or (
800 resource_variable_ops.is_resource_variable(v) and
801 not v._in_graph_mode): # pylint: disable=protected-access
802 scope_name = v.name.split(":")[0]
803 else:
804 scope_name = v.op.name
805
806 # device_policy is set because non-mirrored tensors will be read in
807 # `update_op`. `_resource_apply_dense`, `lr_t`, `beta1_t` and `beta2_t`
808 # is an example.
809 with ops.name_scope("update_" + scope_name):
810 return p.update_op(self, g)
811
812 with ops.name_scope(name, self._name) as sname:
813 self._prepare()

Callers 15

parse_parquetFunction · 0.45
_loadMethod · 0.45
_loadMethod · 0.45
upload_benchmark_dataFunction · 0.45
build_name_from_slicesFunction · 0.45
__init__Method · 0.45
_get_applicable_dictMethod · 0.45
__init__Method · 0.45
all_renames_v2.pyFile · 0.45
AddOpMethod · 0.45
_get_modulesFunction · 0.45

Calls 5

executing_eagerlyMethod · 0.80
_get_processorFunction · 0.70
splitMethod · 0.45
name_scopeMethod · 0.45
update_opMethod · 0.45

Tested by 10

upload_benchmark_dataFunction · 0.36
__init__Method · 0.36
_get_modulesFunction · 0.36
_parse_exampleMethod · 0.36
fake_tfFunction · 0.36
compiledMethod · 0.36
__init__Method · 0.36