tf.parallel_stack
Stay organized with collections
Save and categorize content based on your preferences.
Stacks a list of rank-R
tensors into one rank-(R+1)
tensor in parallel.
tf.parallel_stack(
values, name='parallel_stack'
)
Requires that the shape of inputs be known at graph construction time.
Packs the list of tensors in values
into a tensor with rank one higher than
each tensor in values
, by packing them along the first dimension.
Given a list of length N
of tensors of shape (A, B, C)
; the output
tensor will have the shape (N, A, B, C)
.
For example:
x = tf.constant([1, 4])
y = tf.constant([2, 5])
z = tf.constant([3, 6])
tf.parallel_stack([x, y, z]) # [[1, 4], [2, 5], [3, 6]]
The difference between stack
and parallel_stack
is that stack
requires
all the inputs be computed before the operation will begin but doesn't require
that the input shapes be known during graph construction.
parallel_stack
will copy pieces of the input into the output as they become
available, in some situations this can provide a performance benefit.
Unlike stack
, parallel_stack
does NOT support backpropagation.
This is the opposite of unstack. The numpy equivalent is
tf.parallel_stack([x, y, z]) = np.asarray([x, y, z])
Args |
values
|
A list of Tensor objects with the same shape and type.
|
name
|
A name for this operation (optional).
|
Returns |
output
|
A stacked Tensor with the same type as values .
|
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.parallel_stack\n\n\u003cbr /\u003e\n\n|---------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------|\n| [TensorFlow 1 version](/versions/r1.15/api_docs/python/tf/parallel_stack) | [View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.2.0/tensorflow/python/ops/array_ops.py#L1230-L1278) |\n\nStacks a list of rank-`R` tensors into one rank-`(R+1)` tensor in parallel.\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.parallel_stack`](/api_docs/python/tf/parallel_stack)\n\n\u003cbr /\u003e\n\n tf.parallel_stack(\n values, name='parallel_stack'\n )\n\nRequires that the shape of inputs be known at graph construction time.\n\nPacks the list of tensors in `values` into a tensor with rank one higher than\neach tensor in `values`, by packing them along the first dimension.\nGiven a list of length `N` of tensors of shape `(A, B, C)`; the `output`\ntensor will have the shape `(N, A, B, C)`.\n\n#### For example:\n\n x = tf.constant([1, 4])\n y = tf.constant([2, 5])\n z = tf.constant([3, 6])\n tf.parallel_stack([x, y, z]) # [[1, 4], [2, 5], [3, 6]]\n\nThe difference between `stack` and `parallel_stack` is that `stack` requires\nall the inputs be computed before the operation will begin but doesn't require\nthat the input shapes be known during graph construction.\n\n`parallel_stack` will copy pieces of the input into the output as they become\navailable, in some situations this can provide a performance benefit.\n\nUnlike `stack`, `parallel_stack` does NOT support backpropagation.\n\nThis is the opposite of unstack. The numpy equivalent is \n\n tf.parallel_stack([x, y, z]) = np.asarray([x, y, z])\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------|----------------------------------------------------------|\n| `values` | A list of `Tensor` objects with the same shape and type. |\n| `name` | A name for this operation (optional). |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|----------|----------------------------------------------------|\n| `output` | A stacked `Tensor` with the same type as `values`. |\n\n\u003cbr /\u003e"]]