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

Function _Index

tensorflow/contrib/recurrent/python/ops/recurrent.py:68–82  ·  view source on GitHub ↗

Returns a structure with `x[index]` for each tensor `x` in the structure. Args: struct: A structure of tensors. index: A scalar integer tensor. Performance is better if `index` is on the host memory. Returns: A structure of tensors congruent to `struct`. For each key in `

(struct, index)

Source from the content-addressed store, hash-verified

66
67
68def _Index(struct, index):
69 """Returns a structure with `x[index]` for each tensor `x` in the structure.
70
71 Args:
72 struct: A structure of tensors.
73 index: A scalar integer tensor. Performance is better if `index` is
74 on the host memory.
75
76 Returns:
77 A structure of tensors congruent to `struct`.
78 For each key in `ret`, `rets[key] = struct[key][index]`.
79 """
80 index = ops.convert_to_tensor(index)
81 index.get_shape().assert_has_rank(0)
82 return nest.map_structure(lambda x: array_ops.gather(x, index), struct)
83
84
85def _Update(struct_acc, struct_x, t):

Callers 3

ForwardLoopBodyMethod · 0.85
BackwardLoopBodyMethod · 0.85
RecurrentFunction · 0.85

Calls 3

assert_has_rankMethod · 0.80
get_shapeMethod · 0.45
gatherMethod · 0.45

Tested by

no test coverage detected