tf.raw_ops.Pack
Stay organized with collections
Save and categorize content based on your preferences.
Packs a list of N
rank-R
tensors into one rank-(R+1)
tensor.
tf.raw_ops.Pack(
values, axis=0, name=None
)
Packs the N
tensors in values
into a tensor with rank one higher than each
tensor in values
, by packing them along the axis
dimension.
Given a list of tensors of shape (A, B, C)
;
if axis == 0
then the output
tensor will have the shape (N, A, B, C)
.
if axis == 1
then the output
tensor will have the shape (A, N, B, C)
.
Etc.
For example:
# 'x' is [1, 4]
# 'y' is [2, 5]
# 'z' is [3, 6]
pack([x, y, z]) => [[1, 4], [2, 5], [3, 6]] # Pack along first dim.
pack([x, y, z], axis=1) => [[1, 2, 3], [4, 5, 6]]
This is the opposite of unpack
.
Args |
values
|
A list of at least 1 Tensor objects with the same type.
Must be of same shape and type.
|
axis
|
An optional int . Defaults to 0 .
Dimension along which to pack. Negative values wrap around, so the
valid range is [-(R+1), R+1) .
|
name
|
A name for the operation (optional).
|
Returns |
A Tensor . Has 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. Some content is licensed under the numpy license.
Last updated 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tf.raw_ops.Pack\n\n\u003cbr /\u003e\n\nPacks a list of `N` rank-`R` tensors into one rank-`(R+1)` tensor.\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.raw_ops.Pack`](https://www.tensorflow.org/api_docs/python/tf/raw_ops/Pack)\n\n\u003cbr /\u003e\n\n tf.raw_ops.Pack(\n values, axis=0, name=None\n )\n\nPacks the `N` tensors in `values` into a tensor with rank one higher than each\ntensor in `values`, by packing them along the `axis` dimension.\nGiven a list of tensors of shape `(A, B, C)`;\n\nif `axis == 0` then the `output` tensor will have the shape `(N, A, B, C)`.\nif `axis == 1` then the `output` tensor will have the shape `(A, N, B, C)`.\nEtc.\n\n#### For example:\n\n # 'x' is [1, 4]\n # 'y' is [2, 5]\n # 'z' is [3, 6]\n pack([x, y, z]) =\u003e [[1, 4], [2, 5], [3, 6]] # Pack along first dim.\n pack([x, y, z], axis=1) =\u003e [[1, 2, 3], [4, 5, 6]]\n\nThis is the opposite of `unpack`.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------|----------------------------------------------------------------------------------------------------------------------------------------|\n| `values` | A list of at least 1 `Tensor` objects with the same type. Must be of same shape and type. |\n| `axis` | An optional `int`. Defaults to `0`. Dimension along which to pack. Negative values wrap around, so the valid range is `[-(R+1), R+1)`. |\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| A `Tensor`. Has the same type as `values`. ||\n\n\u003cbr /\u003e"]]