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

Method update_op

tensorflow/python/training/optimizer.py:141–156  ·  view source on GitHub ↗
(self, optimizer, g)

Source from the content-addressed store, hash-verified

139 return self._v._ref() # pylint: disable=protected-access
140
141 def update_op(self, optimizer, g):
142 if isinstance(g, ops.Tensor):
143 update_op = optimizer._apply_dense(g, self._v) # pylint: disable=protected-access
144 if self._v.constraint is not None:
145 with ops.control_dependencies([update_op]):
146 return self._v.assign(self._v.constraint(self._v))
147 else:
148 return update_op
149 else:
150 assert isinstance(g, ops.IndexedSlices), ("Gradient ", g, " is neither a "
151 "tensor nor IndexedSlices.")
152 if self._v.constraint is not None:
153 raise RuntimeError(
154 "Cannot use a constraint function on a sparse variable.")
155 # pylint: disable=protected-access
156 return optimizer._apply_sparse_duplicate_indices(g, self._v)
157
158
159class _DenseReadResourceVariableProcessor(_OptimizableVariable):

Callers

nothing calls this directly

Calls 5

_apply_denseMethod · 0.45
control_dependenciesMethod · 0.45
assignMethod · 0.45
constraintMethod · 0.45

Tested by

no test coverage detected