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

Function create_zeros_slot

tensorflow/python/training/slot_creator.py:270–300  ·  view source on GitHub ↗

Create a slot initialized to 0 with same shape as the primary object. Args: primary: The primary `Variable` or `Tensor`. name: Name to use for the slot variable. dtype: Type of the slot variable. Defaults to the type of `primary`. colocate_with_primary: Boolean. If True the slot

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

Source from the content-addressed store, hash-verified

268
269
270def create_zeros_slot(primary, name, dtype=None, colocate_with_primary=True, slot_config=None):
271 """Create a slot initialized to 0 with same shape as the primary object.
272
273 Args:
274 primary: The primary `Variable` or `Tensor`.
275 name: Name to use for the slot variable.
276 dtype: Type of the slot variable. Defaults to the type of `primary`.
277 colocate_with_primary: Boolean. If True the slot is located
278 on the same device as `primary`.
279
280 Returns:
281 A `Variable` object.
282 """
283 if dtype is None:
284 dtype = primary.dtype
285 slot_shape = primary.get_shape()
286 if slot_shape.is_fully_defined():
287 initializer = init_ops.zeros_initializer()
288 return create_slot_with_initializer(
289 primary, initializer, slot_shape, dtype, name,
290 colocate_with_primary=colocate_with_primary,
291 slot_config=slot_config)
292 else:
293 if isinstance(primary, variables.Variable):
294 slot_shape = array_ops.shape(primary.initialized_value())
295 else:
296 slot_shape = array_ops.shape(primary)
297 val = array_ops.zeros(slot_shape, dtype=dtype)
298 return create_slot(primary, val, name,
299 colocate_with_primary=colocate_with_primary,
300 slot_config=slot_config)
301
302def _set_init_op_embedding_type_attr(var, embedding_type):
303 var._init_op._set_attr("embedding_variable_type",

Callers

nothing calls this directly

Calls 6

create_slotFunction · 0.85
is_fully_definedMethod · 0.80
get_shapeMethod · 0.45
shapeMethod · 0.45
initialized_valueMethod · 0.45

Tested by

no test coverage detected