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

Class _DenseResourceVariableProcessor

tensorflow/python/training/optimizer.py:178–200  ·  view source on GitHub ↗

Processor for dense ResourceVariables.

Source from the content-addressed store, hash-verified

176
177
178class _DenseResourceVariableProcessor(_OptimizableVariable):
179 """Processor for dense ResourceVariables."""
180
181 def __init__(self, v):
182 self._v = v
183
184 def target(self):
185 return self._v
186
187 def update_op(self, optimizer, g):
188 # pylint: disable=protected-access
189 if isinstance(g, ops.IndexedSlices):
190 if self._v.constraint is not None:
191 raise RuntimeError(
192 "Cannot use a constraint function on a sparse variable.")
193 return optimizer._resource_apply_sparse_duplicate_indices(
194 g.values, self._v, g.indices)
195 update_op = optimizer._resource_apply_dense(g, self._v)
196 if self._v.constraint is not None:
197 with ops.control_dependencies([update_op]):
198 return self._v.assign(self._v.constraint(self._v))
199 else:
200 return update_op
201
202
203class _HashTableProcessor(_OptimizableVariable):

Callers 1

_get_processorFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected