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

Function _Pack

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

Packs the list of tensors according to the structure. In the event that `elements` should be a scalar, `struct_template` must contain exactly one non-trivial element (for instance, `[[], {'x':elt}]`). Args: elements: Elements to be packed. A list of tensor, or a single tensor. struct

(elements, struct_template)

Source from the content-addressed store, hash-verified

137
138
139def _Pack(elements, struct_template):
140 """Packs the list of tensors according to the structure.
141
142 In the event that `elements` should be a scalar, `struct_template` must
143 contain exactly one non-trivial element (for instance, `[[], {'x':elt}]`).
144
145 Args:
146 elements: Elements to be packed. A list of tensor, or a single tensor.
147 struct_template: The container structure in which to pack them.
148 Returns:
149 A python structure of the same type as `struct_template`, containing
150 `elements` as its contained elements.
151 """
152 if not nest.is_sequence(elements):
153 return nest.pack_sequence_as(struct_template, [elements])
154 return nest.pack_sequence_as(struct_template, elements)
155
156
157def _EmptyAcc(slen, struct_template):

Callers 11

FwdMethod · 0.85
ForwardLoopBodyMethod · 0.85
GradMethod · 0.85
ForwardMethod · 0.85
BakMethod · 0.85
ReturnOrigState0Method · 0.85
ReturnAccStateMethod · 0.85
BackwardLoopBodyMethod · 0.85
BackwardMethod · 0.85
ComputeMethod · 0.85
CellGradFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected