tf.unstack
tf.unstack
tf.unstack
unstack( value, num=None, axis=0, name='unstack' )
Defined in tensorflow/python/ops/array_ops.py
.
See the guide: Tensor Transformations > Slicing and Joining
Unpacks the given dimension of a rank-R
tensor into rank-(R-1)
tensors.
Unpacks num
tensors from value
by chipping it along the axis
dimension. If num
is not specified (the default), it is inferred from value
's shape. If value.shape[axis]
is not known, ValueError
is raised.
For example, given a tensor of shape (A, B, C, D)
;
If axis == 0
then the i'th tensor in output
is the slice value[i, :, :, :]
and each tensor in output
will have shape (B, C, D)
. (Note that the dimension unpacked along is gone, unlike split
).
If axis == 1
then the i'th tensor in output
is the slice value[:, i, :, :]
and each tensor in output
will have shape (A, C, D)
. Etc.
This is the opposite of pack. The numpy equivalent is
tf.unstack(x, n) = list(x)
Args:
-
value
: A rankR > 0
Tensor
to be unstacked. -
num
: Anint
. The length of the dimensionaxis
. Automatically inferred ifNone
(the default). -
axis
: Anint
. The axis to unstack along. Defaults to the first dimension. Supports negative indexes. -
name
: A name for the operation (optional).
Returns:
The list of Tensor
objects unstacked from value
.
Raises:
-
ValueError
: Ifnum
is unspecified and cannot be inferred. -
ValueError
: Ifaxis
is out of the range [-R, R).
© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/python/tf/unstack