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

Function create_slot

tensorflow/python/training/slot_creator.py:189–220  ·  view source on GitHub ↗

Create a slot initialized to the given value. The type of the slot is determined by the given value. Args: primary: The primary `Variable` or `Tensor`. val: A `Tensor` specifying the initial value of the slot. name: Name to use for the slot variable. colocate_with_primary: Bool

(primary, val, name, colocate_with_primary=True, slot_config=None)

Source from the content-addressed store, hash-verified

187
188
189def create_slot(primary, val, name, colocate_with_primary=True, slot_config=None):
190 """Create a slot initialized to the given value.
191
192 The type of the slot is determined by the given value.
193
194 Args:
195 primary: The primary `Variable` or `Tensor`.
196 val: A `Tensor` specifying the initial value of the slot.
197 name: Name to use for the slot variable.
198 colocate_with_primary: Boolean. If True the slot is located
199 on the same device as `primary`.
200
201 Returns:
202 A `Variable` object.
203 """
204 # Scope the slot name in the namespace of the primary variable.
205 # Set "primary.op.name + '/' + name" as default name, so the scope name of
206 # optimizer can be shared when reuse is True. Meanwhile when reuse is False
207 # and the same name has been previously used, the scope name will add '_N'
208 # as suffix for unique identifications.
209 validate_shape = val.get_shape().is_fully_defined()
210 if context.executing_eagerly():
211 prefix = primary._shared_name # pylint: disable=protected-access
212 else:
213 prefix = primary.op.name
214 with variable_scope.variable_scope(None, prefix + "/" + name):
215 if colocate_with_primary:
216 distribution_strategy = distribution_strategy_context.get_strategy()
217 with distribution_strategy.extended.colocate_vars_with(primary):
218 return _create_slot_var(primary, val, "", validate_shape, None, None, slot_config)
219 else:
220 return _create_slot_var(primary, val, "", validate_shape, None, None, slot_config)
221
222
223def create_slot_with_initializer(primary, initializer, shape, dtype, name,

Callers 1

create_zeros_slotFunction · 0.85

Calls 6

_create_slot_varFunction · 0.85
is_fully_definedMethod · 0.80
executing_eagerlyMethod · 0.80
variable_scopeMethod · 0.80
get_shapeMethod · 0.45
colocate_vars_withMethod · 0.45

Tested by

no test coverage detected