tf.raw_ops.SpaceToBatch
bookmark_borderbookmark
Stay organized with collections
Save and categorize content based on your preferences.
SpaceToBatch for 4-D tensors of type T.
View aliases
Compat aliases for migration
See
Migration guide for
more details.
tf.compat.v1.raw_ops.SpaceToBatch
tf.raw_ops.SpaceToBatch(
input, paddings, block_size, name=None
)
This is a legacy version of the more general SpaceToBatchND.
Zero-pads and then rearranges (permutes) blocks of spatial data into batch.
More specifically, this op outputs a copy of the input tensor where values from
the height
and width
dimensions are moved to the batch
dimension. After
the zero-padding, both height
and width
of the input must be divisible by the
block size.
The attr block_size
must be greater than one. It indicates the block size.
- Non-overlapping blocks of size
block_size x block size
in the height and
width dimensions are rearranged into the batch dimension at each location.
- The batch of the output tensor is
batch * block_size * block_size
.
- Both height_pad and width_pad must be divisible by block_size.
The shape of the output will be:
[batch*block_size*block_size, height_pad/block_size, width_pad/block_size,
depth]
Some examples:
(1) For the following input of shape [1, 2, 2, 1]
and block_size of 2:
x = [[[[1], [2]], [[3], [4]]]]
The output tensor has shape [4, 1, 1, 1]
and value:
[[[[1]]], [[[2]]], [[[3]]], [[[4]]]]
(2) For the following input of shape [1, 2, 2, 3]
and block_size of 2:
x = [[[[1, 2, 3], [4, 5, 6]],
[[7, 8, 9], [10, 11, 12]]]]
The output tensor has shape [4, 1, 1, 3]
and value:
[[[[1, 2, 3]]], [[[4, 5, 6]]], [[[7, 8, 9]]], [[[10, 11, 12]]]]
(3) For the following input of shape [1, 4, 4, 1]
and block_size of 2:
x = [[[[1], [2], [3], [4]],
[[5], [6], [7], [8]],
[[9], [10], [11], [12]],
[[13], [14], [15], [16]]]]
The output tensor has shape [4, 2, 2, 1]
and value:
x = [[[[1], [3]], [[9], [11]]],
[[[2], [4]], [[10], [12]]],
[[[5], [7]], [[13], [15]]],
[[[6], [8]], [[14], [16]]]]
(4) For the following input of shape [2, 2, 4, 1]
and block_size of 2:
x = [[[[1], [2], [3], [4]],
[[5], [6], [7], [8]]],
[[[9], [10], [11], [12]],
[[13], [14], [15], [16]]]]
The output tensor has shape [8, 1, 2, 1]
and value:
x = [[[[1], [3]]], [[[9], [11]]], [[[2], [4]]], [[[10], [12]]],
[[[5], [7]]], [[[13], [15]]], [[[6], [8]]], [[[14], [16]]]]
Among others, this operation is useful for reducing atrous convolution into
regular convolution.
Args |
input
|
A Tensor . 4-D with shape [batch, height, width, depth] .
|
paddings
|
A Tensor . Must be one of the following types: int32 , int64 .
2-D tensor of non-negative integers with shape [2, 2] . It specifies
the padding of the input with zeros across the spatial dimensions as follows:
paddings = [[pad_top, pad_bottom], [pad_left, pad_right]]
The effective spatial dimensions of the zero-padded input tensor will be:
height_pad = pad_top + height + pad_bottom
width_pad = pad_left + width + pad_right
|
block_size
|
An int that is >= 2 .
|
name
|
A name for the operation (optional).
|
Returns |
A Tensor . Has the same type as input .
|
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.
[[["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 2024-04-26 UTC."],[],[],null,["# tf.raw_ops.SpaceToBatch\n\n\u003cbr /\u003e\n\nSpaceToBatch for 4-D tensors of type T.\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.SpaceToBatch`](https://www.tensorflow.org/api_docs/python/tf/raw_ops/SpaceToBatch)\n\n\u003cbr /\u003e\n\n tf.raw_ops.SpaceToBatch(\n input, paddings, block_size, name=None\n )\n\nThis is a legacy version of the more general SpaceToBatchND.\n\nZero-pads and then rearranges (permutes) blocks of spatial data into batch.\nMore specifically, this op outputs a copy of the input tensor where values from\nthe `height` and `width` dimensions are moved to the `batch` dimension. After\nthe zero-padding, both `height` and `width` of the input must be divisible by the\nblock size.\n\nThe attr `block_size` must be greater than one. It indicates the block size.\n\n- Non-overlapping blocks of size `block_size x block size` in the height and width dimensions are rearranged into the batch dimension at each location.\n- The batch of the output tensor is `batch * block_size * block_size`.\n- Both height_pad and width_pad must be divisible by block_size.\n\nThe shape of the output will be: \n\n [batch*block_size*block_size, height_pad/block_size, width_pad/block_size,\n depth]\n\n#### Some examples:\n\n(1) For the following input of shape `[1, 2, 2, 1]` and block_size of 2: \n\n x = [[[[1], [2]], [[3], [4]]]]\n\nThe output tensor has shape `[4, 1, 1, 1]` and value: \n\n [[[[1]]], [[[2]]], [[[3]]], [[[4]]]]\n\n(2) For the following input of shape `[1, 2, 2, 3]` and block_size of 2: \n\n x = [[[[1, 2, 3], [4, 5, 6]],\n [[7, 8, 9], [10, 11, 12]]]]\n\nThe output tensor has shape `[4, 1, 1, 3]` and value: \n\n [[[[1, 2, 3]]], [[[4, 5, 6]]], [[[7, 8, 9]]], [[[10, 11, 12]]]]\n\n(3) For the following input of shape `[1, 4, 4, 1]` and block_size of 2: \n\n x = [[[[1], [2], [3], [4]],\n [[5], [6], [7], [8]],\n [[9], [10], [11], [12]],\n [[13], [14], [15], [16]]]]\n\nThe output tensor has shape `[4, 2, 2, 1]` and value: \n\n x = [[[[1], [3]], [[9], [11]]],\n [[[2], [4]], [[10], [12]]],\n [[[5], [7]], [[13], [15]]],\n [[[6], [8]], [[14], [16]]]]\n\n(4) For the following input of shape `[2, 2, 4, 1]` and block_size of 2: \n\n x = [[[[1], [2], [3], [4]],\n [[5], [6], [7], [8]]],\n [[[9], [10], [11], [12]],\n [[13], [14], [15], [16]]]]\n\nThe output tensor has shape `[8, 1, 2, 1]` and value: \n\n x = [[[[1], [3]]], [[[9], [11]]], [[[2], [4]]], [[[10], [12]]],\n [[[5], [7]]], [[[13], [15]]], [[[6], [8]]], [[[14], [16]]]]\n\nAmong others, this operation is useful for reducing atrous convolution into\nregular convolution.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `input` | A `Tensor`. 4-D with shape `[batch, height, width, depth]`. |\n| `paddings` | A `Tensor`. Must be one of the following types: `int32`, `int64`. 2-D tensor of non-negative integers with shape `[2, 2]`. It specifies the padding of the input with zeros across the spatial dimensions as follows: \u003cbr /\u003e paddings = [[pad_top, pad_bottom], [pad_left, pad_right]] The effective spatial dimensions of the zero-padded input tensor will be: height_pad = pad_top + height + pad_bottom width_pad = pad_left + width + pad_right \u003cbr /\u003e |\n| `block_size` | An `int` that is `\u003e= 2`. |\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 `input`. ||\n\n\u003cbr /\u003e"]]