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

Class TensorArray

tensorflow/python/ops/tensor_array_ops.py:923–1196  ·  view source on GitHub ↗

Class wrapping dynamic-sized, per-time-step, write-once Tensor arrays. This class is meant to be used with dynamic iteration primitives such as `while_loop` and `map_fn`. It supports gradient back-propagation via special "flow" control flow dependencies.

Source from the content-addressed store, hash-verified

921# pylint: disable=protected-access
922@tf_export("TensorArray")
923class TensorArray(object):
924 """Class wrapping dynamic-sized, per-time-step, write-once Tensor arrays.
925
926 This class is meant to be used with dynamic iteration primitives such as
927 `while_loop` and `map_fn`. It supports gradient back-propagation via special
928 "flow" control flow dependencies.
929 """
930
931 def __init__(self,
932 dtype,
933 size=None,
934 dynamic_size=None,
935 clear_after_read=None,
936 tensor_array_name=None,
937 handle=None,
938 flow=None,
939 infer_shape=True,
940 element_shape=None,
941 colocate_with_first_write_call=True,
942 name=None):
943 """Construct a new TensorArray or wrap an existing TensorArray handle.
944
945 A note about the parameter `name`:
946
947 The name of the `TensorArray` (even if passed in) is uniquified: each time
948 a new `TensorArray` is created at runtime it is assigned its own name for
949 the duration of the run. This avoids name collisions if a `TensorArray`
950 is created within a `while_loop`.
951
952 Args:
953 dtype: (required) data type of the TensorArray.
954 size: (optional) int32 scalar `Tensor`: the size of the TensorArray.
955 Required if handle is not provided.
956 dynamic_size: (optional) Python bool: If true, writes to the TensorArray
957 can grow the TensorArray past its initial size. Default: False.
958 clear_after_read: Boolean (optional, default: True). If True, clear
959 TensorArray values after reading them. This disables read-many
960 semantics, but allows early release of memory.
961 tensor_array_name: (optional) Python string: the name of the TensorArray.
962 This is used when creating the TensorArray handle. If this value is
963 set, handle should be None.
964 handle: (optional) A `Tensor` handle to an existing TensorArray. If this
965 is set, tensor_array_name should be None. Only supported in graph mode.
966 flow: (optional) A float `Tensor` scalar coming from an existing
967 `TensorArray.flow`. Only supported in graph mode.
968 infer_shape: (optional, default: True) If True, shape inference
969 is enabled. In this case, all elements must have the same shape.
970 element_shape: (optional, default: None) A `TensorShape` object specifying
971 the shape constraints of each of the elements of the TensorArray.
972 Need not be fully defined.
973 colocate_with_first_write_call: If `True`, the TensorArray will be
974 colocated on the same device as the Tensor used on its first write
975 (write operations include `write`, `unstack`, and `split`). If `False`,
976 the TensorArray will be placed on the device determined by the
977 device context available during its initialization.
978 name: A name for the operation (optional).
979
980 Raises:

Callers 3

gradMethod · 0.70
build_ta_with_new_flowFunction · 0.70
_from_componentsMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected