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

Method get_slot

tensorflow/python/training/optimizer.py:857–893  ·  view source on GitHub ↗

Return a slot named `name` created for `var` by the Optimizer. Some `Optimizer` subclasses use additional variables. For example `Momentum` and `Adagrad` use variables to accumulate updates. This method gives access to these `Variable` objects if for some reason you need them. Us

(self, var, name)

Source from the content-addressed store, hash-verified

855 return apply_fn()
856
857 def get_slot(self, var, name):
858 """Return a slot named `name` created for `var` by the Optimizer.
859
860 Some `Optimizer` subclasses use additional variables. For example
861 `Momentum` and `Adagrad` use variables to accumulate updates. This method
862 gives access to these `Variable` objects if for some reason you need them.
863
864 Use `get_slot_names()` to get the list of slot names created by the
865 `Optimizer`.
866
867 Args:
868 var: A variable passed to `minimize()` or `apply_gradients()`.
869 name: A string.
870
871 Returns:
872 The `Variable` for the slot if it was created, `None` otherwise.
873 """
874 # pylint: disable=protected-access
875 named_slots = self._slots.get(name, None)
876 if not named_slots:
877 return None
878
879 if hasattr(var, "_distributed_container"):
880 # NOTE: If this isn't patched, then there is no `handle` in
881 # `_resource_apply_dense`.
882 distributed_container = var._distributed_container()
883 assert distributed_container is not None
884 if ops.executing_eagerly_outside_functions():
885 key = distributed_container._unique_id
886 else:
887 key = (distributed_container.graph, distributed_container._shared_name)
888 # pylint: enable=protected-access
889 mirrored_slot = named_slots.get(key, None)
890 if mirrored_slot is None: return None
891 return mirrored_slot.get(device=var.device)
892
893 return named_slots.get(_var_key(var), None)
894
895 def get_slot_names(self):
896 """Return a list of the names of slots created by the `Optimizer`.

Callers 15

apply_fnMethod · 0.95
doTestBasicMethod · 0.45
_apply_denseMethod · 0.45
_resource_apply_denseMethod · 0.45
_apply_sparseMethod · 0.45
doTestBasicMethod · 0.45
doTestSparseBasicMethod · 0.45
doTestBaselineMethod · 0.45
doTestSparseBaselineMethod · 0.45
_initialized_modelMethod · 0.45
_set_sentinelsMethod · 0.45

Calls 2

_var_keyFunction · 0.70
getMethod · 0.45

Tested by 15

doTestBasicMethod · 0.36
doTestBasicMethod · 0.36
doTestSparseBasicMethod · 0.36
doTestBaselineMethod · 0.36
doTestSparseBaselineMethod · 0.36
_initialized_modelMethod · 0.36
_set_sentinelsMethod · 0.36
_check_sentinelsMethod · 0.36
doTestSparseMethod · 0.36
doTestBasicMethod · 0.36
testSharingMethod · 0.36