/TensorFlow 2.4

# tf.raw_ops.SpaceToBatch

SpaceToBatch for 4-D tensors of type T.

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.

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:

The effective spatial dimensions of the zero-padded input tensor will be:

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`.

The shape of the output will be:

Some examples:

(1) For the following input of shape `[1, 2, 2, 1]` and block_size of 2:

```x = [[[, ], [, ]]]
```

The output tensor has shape `[4, 1, 1, 1]` and value:

```[[[]], [[]], [[]], [[]]]
```

(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 = [[[,   ,  ,  ],
[,   ,  ,  ],
[,  , ,  ],
[, , ,  ]]]
```

The output tensor has shape `[4, 2, 2, 1]` and value:

```x = [[[, ], [, ]],
[[, ], [, ]],
[[, ], [, ]],
[[, ], [, ]]]
```

(4) For the following input of shape `[2, 2, 4, 1]` and block_size of 2:

```x = [[[,   ,  ,  ],
[,   ,  ,  ]],
[[,  , ,  ],
[, , ,  ]]]
```

The output tensor has shape `[8, 1, 2, 1]` and value:

```x = [[[, ]], [[, ]], [[, ]], [[, ]],
[[, ]], [[, ]], [[, ]], [[, ]]]
```

Among others, this operation is useful for reducing atrous convolution into regular convolution.

`block_size` An `int` that is `>= 2`.
`name` A name for the operation (optional).
Returns
A `Tensor`. Has the same type as `input`.