LostTech.TensorFlow : API Documentation

Type TensorArray

Namespace tensorflow

Parent PythonObjectContainer

Interfaces ITensorArray

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.

Methods

Properties

Public instance methods

object close(string name)

Close the current TensorArray.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

object close_dyn(object name)

Close the current TensorArray.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

Tensor concat(string name)

Return the values in the TensorArray as a concatenated `Tensor`.

All of the values must have been written, their ranks must match, and and their shapes must all match for all dimensions except the first.
Parameters
string name
A name for the operation (optional).
Returns
Tensor
All the tensors in the TensorArray concatenated into one tensor.

object concat_dyn(object name)

Return the values in the TensorArray as a concatenated `Tensor`.

All of the values must have been written, their ranks must match, and and their shapes must all match for all dimensions except the first.
Parameters
object name
A name for the operation (optional).
Returns
object
All the tensors in the TensorArray concatenated into one tensor.

Tensor gather(IGraphNodeBase indices, string name)

Return selected values in the TensorArray as a packed `Tensor`.

All of selected values must have been written and their shapes must all match.
Parameters
IGraphNodeBase indices
A `1-D` `Tensor` taking values in `[0, max_value)`. If the `TensorArray` is not dynamic, `max_value=size()`.
string name
A name for the operation (optional).
Returns
Tensor
The tensors in the `TensorArray` selected by `indices`, packed into one tensor.

Tensor gather(IEnumerable<object> indices, string name)

Return selected values in the TensorArray as a packed `Tensor`.

All of selected values must have been written and their shapes must all match.
Parameters
IEnumerable<object> indices
A `1-D` `Tensor` taking values in `[0, max_value)`. If the `TensorArray` is not dynamic, `max_value=size()`.
string name
A name for the operation (optional).
Returns
Tensor
The tensors in the `TensorArray` selected by `indices`, packed into one tensor.

object gather_dyn(object indices, object name)

Return selected values in the TensorArray as a packed `Tensor`.

All of selected values must have been written and their shapes must all match.
Parameters
object indices
A `1-D` `Tensor` taking values in `[0, max_value)`. If the `TensorArray` is not dynamic, `max_value=size()`.
object name
A name for the operation (optional).
Returns
object
The tensors in the `TensorArray` selected by `indices`, packed into one tensor.

TensorArray grad(string source, object flow, string name)

object grad_dyn(object source, object flow, object name)

TensorArray identity()

Returns a TensorArray with the same content and properties.
Returns
TensorArray
A new TensorArray object with flow that ensures the control dependencies from the contexts will become control dependencies for writes, reads, etc. Use this object all for subsequent operations.

object identity_dyn()

Returns a TensorArray with the same content and properties.
Returns
object
A new TensorArray object with flow that ensures the control dependencies from the contexts will become control dependencies for writes, reads, etc. Use this object all for subsequent operations.

Tensor read(object index, string name)

Read the value at location `index` in the TensorArray.
Parameters
object index
0-D. int32 tensor with the index to read from.
string name
A name for the operation (optional).
Returns
Tensor
The tensor at index `index`.

Tensor read(int index, string name)

Read the value at location `index` in the TensorArray.
Parameters
int index
0-D. int32 tensor with the index to read from.
string name
A name for the operation (optional).
Returns
Tensor
The tensor at index `index`.

Tensor read(Dimension index, string name)

Read the value at location `index` in the TensorArray.
Parameters
Dimension index
0-D. int32 tensor with the index to read from.
string name
A name for the operation (optional).
Returns
Tensor
The tensor at index `index`.

Tensor read(IEnumerable<object> index, string name)

Read the value at location `index` in the TensorArray.
Parameters
IEnumerable<object> index
0-D. int32 tensor with the index to read from.
string name
A name for the operation (optional).
Returns
Tensor
The tensor at index `index`.

TensorArray scatter(IGraphNodeBase indices, IGraphNodeBase value, string name)

Scatter the values of a `Tensor` in specific indices of a `TensorArray`.

Args: indices: A `1-D` `Tensor` taking values in `[0, max_value)`. If the `TensorArray` is not dynamic, `max_value=size()`. value: (N+1)-D. Tensor of type `dtype`. The Tensor to unpack. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the scatter occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

TensorArray scatter(IGraphNodeBase indices, IEnumerable<double> value, string name)

Scatter the values of a `Tensor` in specific indices of a `TensorArray`.

Args: indices: A `1-D` `Tensor` taking values in `[0, max_value)`. If the `TensorArray` is not dynamic, `max_value=size()`. value: (N+1)-D. Tensor of type `dtype`. The Tensor to unpack. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the scatter occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

TensorArray scatter(IEnumerable<int> indices, IGraphNodeBase value, string name)

Scatter the values of a `Tensor` in specific indices of a `TensorArray`.

Args: indices: A `1-D` `Tensor` taking values in `[0, max_value)`. If the `TensorArray` is not dynamic, `max_value=size()`. value: (N+1)-D. Tensor of type `dtype`. The Tensor to unpack. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the scatter occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

TensorArray scatter(IEnumerable<int> indices, IEnumerable<double> value, string name)

Scatter the values of a `Tensor` in specific indices of a `TensorArray`.

Args: indices: A `1-D` `Tensor` taking values in `[0, max_value)`. If the `TensorArray` is not dynamic, `max_value=size()`. value: (N+1)-D. Tensor of type `dtype`. The Tensor to unpack. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the scatter occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

object scatter_dyn(object indices, object value, object name)

Scatter the values of a `Tensor` in specific indices of a `TensorArray`.

Args: indices: A `1-D` `Tensor` taking values in `[0, max_value)`. If the `TensorArray` is not dynamic, `max_value=size()`. value: (N+1)-D. Tensor of type `dtype`. The Tensor to unpack. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the scatter occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

TensorArray split(IEnumerable<double> value, IEnumerable<int> lengths, string name)

Split the values of a `Tensor` into the TensorArray.

Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to split. lengths: 1-D. int32 vector with the lengths to use when splitting `value` along its first dimension. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the split occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

TensorArray split(double value, IEnumerable<int> lengths, string name)

Split the values of a `Tensor` into the TensorArray.

Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to split. lengths: 1-D. int32 vector with the lengths to use when splitting `value` along its first dimension. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the split occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

TensorArray split(IEnumerable<double> value, int lengths, string name)

Split the values of a `Tensor` into the TensorArray.

Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to split. lengths: 1-D. int32 vector with the lengths to use when splitting `value` along its first dimension. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the split occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

TensorArray split(IGraphNodeBase value, IEnumerable<int> lengths, string name)

Split the values of a `Tensor` into the TensorArray.

Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to split. lengths: 1-D. int32 vector with the lengths to use when splitting `value` along its first dimension. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the split occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

TensorArray split(double value, int lengths, string name)

Split the values of a `Tensor` into the TensorArray.

Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to split. lengths: 1-D. int32 vector with the lengths to use when splitting `value` along its first dimension. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the split occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

TensorArray split(IGraphNodeBase value, int lengths, string name)

Split the values of a `Tensor` into the TensorArray.

Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to split. lengths: 1-D. int32 vector with the lengths to use when splitting `value` along its first dimension. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the split occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

TensorArray split(IGraphNodeBase value, IGraphNodeBase lengths, string name)

Split the values of a `Tensor` into the TensorArray.

Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to split. lengths: 1-D. int32 vector with the lengths to use when splitting `value` along its first dimension. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the split occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

TensorArray split(IEnumerable<double> value, IGraphNodeBase lengths, string name)

Split the values of a `Tensor` into the TensorArray.

Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to split. lengths: 1-D. int32 vector with the lengths to use when splitting `value` along its first dimension. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the split occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

TensorArray split(double value, IGraphNodeBase lengths, string name)

Split the values of a `Tensor` into the TensorArray.

Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to split. lengths: 1-D. int32 vector with the lengths to use when splitting `value` along its first dimension. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the split occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

object split_dyn(object value, object lengths, object name)

Split the values of a `Tensor` into the TensorArray.

Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to split. lengths: 1-D. int32 vector with the lengths to use when splitting `value` along its first dimension. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the split occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

Tensor stack(string name)

Return the values in the TensorArray as a stacked `Tensor`.

All of the values must have been written and their shapes must all match. If input shapes have rank-`R`, then output shape will have rank-`(R+1)`.
Parameters
string name
A name for the operation (optional).
Returns
Tensor
All the tensors in the TensorArray stacked into one tensor.

object stack_dyn(object name)

Return the values in the TensorArray as a stacked `Tensor`.

All of the values must have been written and their shapes must all match. If input shapes have rank-`R`, then output shape will have rank-`(R+1)`.
Parameters
object name
A name for the operation (optional).
Returns
object
All the tensors in the TensorArray stacked into one tensor.

TensorArray unstack(IEnumerable<IGraphNodeBase> value, string name)

Unstack the values of a `Tensor` in the TensorArray.

If input value shapes have rank-`R`, then the output TensorArray will contain elements whose shapes are rank-`(R-1)`.

Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to unstack. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the unstack occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

TensorArray unstack(object value, string name)

Unstack the values of a `Tensor` in the TensorArray.

If input value shapes have rank-`R`, then the output TensorArray will contain elements whose shapes are rank-`(R-1)`.

Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to unstack. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the unstack occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

object unstack_dyn(object value, object name)

Unstack the values of a `Tensor` in the TensorArray.

If input value shapes have rank-`R`, then the output TensorArray will contain elements whose shapes are rank-`(R-1)`.

Args: value: (N+1)-D. Tensor of type `dtype`. The Tensor to unstack. name: A name for the operation (optional).

Returns: A new TensorArray object with flow that ensures the unstack occurs. Use this object all for subsequent operations.

Raises: ValueError: if the shape inference fails.

**NOTE** The output of this function should be used. If it is not, a warning will be logged. To mark the output as used, call its.mark_used() method.

TensorArray write(TensorArray index, IEnumerable<object> value, string name)

Write `value` into index `index` of the TensorArray.
Parameters
TensorArray index
0-D. int32 scalar with the index to write to.
IEnumerable<object> value
N-D. Tensor of type `dtype`. The Tensor to write to this index.
string name
A name for the operation (optional).
Returns
TensorArray
A new TensorArray object with flow that ensures the write occurs. Use this object all for subsequent operations.

TensorArray write(TensorArray index, object value, string name)

Write `value` into index `index` of the TensorArray.
Parameters
TensorArray index
0-D. int32 scalar with the index to write to.
object value
N-D. Tensor of type `dtype`. The Tensor to write to this index.
string name
A name for the operation (optional).
Returns
TensorArray
A new TensorArray object with flow that ensures the write occurs. Use this object all for subsequent operations.

TensorArray write(IGraphNodeBase index, IEnumerable<object> value, string name)

Write `value` into index `index` of the TensorArray.
Parameters
IGraphNodeBase index
0-D. int32 scalar with the index to write to.
IEnumerable<object> value
N-D. Tensor of type `dtype`. The Tensor to write to this index.
string name
A name for the operation (optional).
Returns
TensorArray
A new TensorArray object with flow that ensures the write occurs. Use this object all for subsequent operations.

TensorArray write(int index, IEnumerable<object> value, string name)

Write `value` into index `index` of the TensorArray.
Parameters
int index
0-D. int32 scalar with the index to write to.
IEnumerable<object> value
N-D. Tensor of type `dtype`. The Tensor to write to this index.
string name
A name for the operation (optional).
Returns
TensorArray
A new TensorArray object with flow that ensures the write occurs. Use this object all for subsequent operations.

TensorArray write(IGraphNodeBase index, object value, string name)

Write `value` into index `index` of the TensorArray.
Parameters
IGraphNodeBase index
0-D. int32 scalar with the index to write to.
object value
N-D. Tensor of type `dtype`. The Tensor to write to this index.
string name
A name for the operation (optional).
Returns
TensorArray
A new TensorArray object with flow that ensures the write occurs. Use this object all for subsequent operations.

TensorArray write(int index, object value, string name)

Write `value` into index `index` of the TensorArray.
Parameters
int index
0-D. int32 scalar with the index to write to.
object value
N-D. Tensor of type `dtype`. The Tensor to write to this index.
string name
A name for the operation (optional).
Returns
TensorArray
A new TensorArray object with flow that ensures the write occurs. Use this object all for subsequent operations.

object write_dyn(object index, object value, object name)

Write `value` into index `index` of the TensorArray.
Parameters
object index
0-D. int32 scalar with the index to write to.
object value
N-D. Tensor of type `dtype`. The Tensor to write to this index.
object name
A name for the operation (optional).
Returns
object
A new TensorArray object with flow that ensures the write occurs. Use this object all for subsequent operations.

Public static methods

TensorArray NewDyn(object dtype, object size, object dynamic_size, object clear_after_read, object tensor_array_name, object handle, object flow, ImplicitContainer<T> infer_shape, object element_shape, ImplicitContainer<T> colocate_with_first_write_call, object name)

Construct a new TensorArray or wrap an existing TensorArray handle.

A note about the parameter `name`:

The name of the `TensorArray` (even if passed in) is uniquified: each time a new `TensorArray` is created at runtime it is assigned its own name for the duration of the run. This avoids name collisions if a `TensorArray` is created within a `while_loop`.
Parameters
object dtype
(required) data type of the TensorArray.
object size
(optional) int32 scalar `Tensor`: the size of the TensorArray. Required if handle is not provided.
object dynamic_size
(optional) Python bool: If true, writes to the TensorArray can grow the TensorArray past its initial size. Default: False.
object clear_after_read
Boolean (optional, default: True). If True, clear TensorArray values after reading them. This disables read-many semantics, but allows early release of memory.
object tensor_array_name
(optional) Python string: the name of the TensorArray. This is used when creating the TensorArray handle. If this value is set, handle should be None.
object handle
(optional) A `Tensor` handle to an existing TensorArray. If this is set, tensor_array_name should be None. Only supported in graph mode.
object flow
(optional) A float `Tensor` scalar coming from an existing `TensorArray.flow`. Only supported in graph mode.
ImplicitContainer<T> infer_shape
(optional, default: True) If True, shape inference is enabled. In this case, all elements must have the same shape.
object element_shape
(optional, default: None) A `TensorShape` object specifying the shape constraints of each of the elements of the TensorArray. Need not be fully defined.
ImplicitContainer<T> colocate_with_first_write_call
If `True`, the TensorArray will be colocated on the same device as the Tensor used on its first write (write operations include `write`, `unstack`, and `split`). If `False`, the TensorArray will be placed on the device determined by the device context available during its initialization.
object name
A name for the operation (optional).

Public properties

DType dtype get;

The data type of this TensorArray.

object dtype_dyn get;

The data type of this TensorArray.

Nullable<bool> dynamic_size get;

Python bool; if `True` the TensorArray can grow dynamically.

object dynamic_size_dyn get;

Python bool; if `True` the TensorArray can grow dynamically.

object element_shape get;

The tf.TensorShape of elements in this TensorArray.

object element_shape_dyn get;

The tf.TensorShape of elements in this TensorArray.

Tensor flow get;

The flow `Tensor` forcing ops leading to this TensorArray state.

object flow_dyn get;

The flow `Tensor` forcing ops leading to this TensorArray state.

object handle get;

The reference to the TensorArray.

object handle_dyn get;

The reference to the TensorArray.

object PythonObject get;