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

Method __init__

tensorflow/python/ops/tensor_array_ops.py:53–164  ·  view source on GitHub ↗

Constructs a graph mode TensorArray. Args: dtype: (required) data type of the TensorArray. size: (optional) int32 scalar `Tensor`: the size of the TensorArray. Required if handle is not provided. dynamic_size: (optional) Python bool: If true, writes to the TensorArray

(self,
               dtype,
               size=None,
               dynamic_size=None,
               clear_after_read=None,
               tensor_array_name=None,
               handle=None,
               flow=None,
               infer_shape=True,
               element_shape=None,
               colocate_with_first_write_call=True,
               name=None)

Source from the content-addressed store, hash-verified

51 """
52
53 def __init__(self,
54 dtype,
55 size=None,
56 dynamic_size=None,
57 clear_after_read=None,
58 tensor_array_name=None,
59 handle=None,
60 flow=None,
61 infer_shape=True,
62 element_shape=None,
63 colocate_with_first_write_call=True,
64 name=None):
65 """Constructs a graph mode TensorArray.
66
67 Args:
68 dtype: (required) data type of the TensorArray.
69 size: (optional) int32 scalar `Tensor`: the size of the TensorArray.
70 Required if handle is not provided.
71 dynamic_size: (optional) Python bool: If true, writes to the TensorArray
72 can grow the TensorArray past its initial size. Default: False.
73 clear_after_read: Boolean (optional, default: True). If True, clear
74 TensorArray values after reading them. This disables read-many
75 semantics, but allows early release of memory.
76 tensor_array_name: (optional) Python string: the name of the TensorArray.
77 This is used when creating the TensorArray handle. If this value is
78 set, handle should be None.
79 handle: (optional) A `Tensor` handle to an existing TensorArray. If this
80 is set, tensor_array_name should be None. Only supported in graph mode.
81 flow: (optional) A float `Tensor` scalar coming from an existing
82 `TensorArray.flow`. Only supported in graph mode.
83 infer_shape: (optional, default: True) If True, shape inference
84 is enabled. In this case, all elements must have the same shape.
85 element_shape: (optional, default: None) A `TensorShape` object specifying
86 the shape constraints of each of the elements of the TensorArray.
87 Need not be fully defined.
88 colocate_with_first_write_call: If `True`, the TensorArray will be
89 colocated on the same device as the Tensor used on its first write
90 (write operations include `write`, `unstack`, and `split`). If `False`,
91 the TensorArray will be placed on the device determined by the
92 device context available during its initialization.
93 name: A name for the operation (optional).
94
95 Raises:
96 ValueError: if both handle and tensor_array_name are provided.
97 TypeError: if handle is provided but is not a Tensor.
98 """
99 if handle is not None and tensor_array_name:
100 raise ValueError(
101 "Cannot construct with both handle and tensor_array_name")
102 if handle is not None and not isinstance(handle, ops.Tensor):
103 raise TypeError("Handle must be a Tensor")
104 if handle is None and size is None:
105 raise ValueError("Size must be provided if handle is not provided")
106 if handle is not None and size is not None:
107 raise ValueError("Cannot provide both a handle and size "
108 "at the same time")
109 if handle is not None and element_shape is not None:
110 raise ValueError("Cannot provide both a handle and element_shape "

Callers

nothing calls this directly

Calls 4

createFunction · 0.85
colocate_withMethod · 0.80
name_scopeMethod · 0.45
deviceMethod · 0.45

Tested by

no test coverage detected