tf.unstack
Stay organized with collections
Save and categorize content based on your preferences.
Unpacks the given dimension of a rank-R
tensor into rank-(R-1)
tensors.
tf.unstack(
value, num=None, axis=0, name='unstack'
)
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 stack.
Args |
value
|
A rank R > 0 Tensor to be unstacked.
|
num
|
An int . The length of the dimension axis . Automatically inferred if
None (the default).
|
axis
|
An int . The axis to unstack along. Defaults to the first dimension.
Negative values wrap around, so the valid range is [-R, R) .
|
name
|
A name for the operation (optional).
|
Returns |
The list of Tensor objects unstacked from value .
|
Raises |
ValueError
|
If num is unspecified and cannot be inferred.
|
ValueError
|
If axis is out of the range [-R, R).
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2020-10-01 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2020-10-01 UTC."],[],[],null,["# tf.unstack\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/unstack) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.0.0/tensorflow/python/ops/array_ops.py#L1289-L1334) |\n\nUnpacks the given dimension of a rank-`R` tensor into rank-`(R-1)` tensors.\n\n#### View aliases\n\n\n**Compat aliases for migration**\n\nSee\n[Migration guide](https://www.tensorflow.org/guide/migrate) for\nmore details.\n\n[`tf.compat.v1.unstack`](/api_docs/python/tf/unstack)\n\n\u003cbr /\u003e\n\n tf.unstack(\n value, num=None, axis=0, name='unstack'\n )\n\nUnpacks `num` tensors from `value` by chipping it along the `axis` dimension.\nIf `num` is not specified (the default), it is inferred from `value`'s shape.\nIf `value.shape[axis]` is not known, `ValueError` is raised.\n\nFor example, given a tensor of shape `(A, B, C, D)`;\n\nIf `axis == 0` then the i'th tensor in `output` is the slice\n`value[i, :, :, :]` and each tensor in `output` will have shape `(B, C, D)`.\n(Note that the dimension unpacked along is gone, unlike `split`).\n\nIf `axis == 1` then the i'th tensor in `output` is the slice\n`value[:, i, :, :]` and each tensor in `output` will have shape `(A, C, D)`.\nEtc.\n\nThis is the opposite of stack.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------|-------------------------------------------------------------------------------------------------------------------------------------|\n| `value` | A rank `R \u003e 0` `Tensor` to be unstacked. |\n| `num` | An `int`. The length of the dimension `axis`. Automatically inferred if `None` (the default). |\n| `axis` | An `int`. The axis to unstack along. Defaults to the first dimension. Negative values wrap around, so the valid range is `[-R, R)`. |\n| `name` | A name for the operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| The list of `Tensor` objects unstacked from `value`. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|-------------------------------------------------|\n| `ValueError` | If `num` is unspecified and cannot be inferred. |\n| `ValueError` | If `axis` is out of the range \\[-R, R). |\n\n\u003cbr /\u003e"]]