# tensorflow::ops::BatchToSpace Class Reference

# tensorflow::
ops::
BatchToSpace

`
#include <array_ops.h>
`


[BatchToSpace](https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/batch-to-space#classtensorflow_1_1ops_1_1_batch_to_space)
for 4-D tensors of type T.

## Summary


This is a legacy version of the more general
[BatchToSpaceND](https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/batch-to-space-n-d#classtensorflow_1_1ops_1_1_batch_to_space_n_d)
.


Rearranges (permutes) data from batch into blocks of spatial data, followed by cropping. This is the reverse transformation of SpaceToBatch. More specifically, this op outputs a copy of the input tensor where values from the
`
batch
`
dimension are moved in spatial blocks to the
`
height
`
and
`
width
`
dimensions, followed by cropping along the
`
height
`
and
`
width
`
dimensions.


Args:

- scope: A [Scope](https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope) object
- input: 4-D tensor with shape `
  [batch*block_size*block_size, height_pad/block_size, width_pad/block_size, depth]
  ` . Note that the batch size of the input tensor must be divisible by `
  block_size * block_size
  ` .
- crops: 2-D tensor of non-negative integers with shape `
  [2, 2]
  ` . It specifies how many elements to crop from the intermediate result across the spatial dimensions as follows:

  ```
  crops = [[crop_top, crop_bottom], [crop_left, crop_right]]
  ```

<br />


Returns:

- `
  https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output
  ` : 4-D with shape `
  [batch, height, width, depth]
  ` , where:

  ```
  height = height_pad - crop_top - crop_bottom
  width = width_pad - crop_left - crop_right
  ```

<br />


The attr
`
block_size
`
must be greater than one. It indicates the block size.


Some examples:


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


```
[[[[1]]], [[[2]]], [[[3]]], [[[4]]]]
```

<br />


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


```
x = [[[[1], [2]], [[3], [4]]]]
```

<br />


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


```
[[[[1, 2, 3]]], [[[4, 5, 6]]], [[[7, 8, 9]]], [[[10, 11, 12]]]]
```

<br />


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


```
x = [[[[1, 2, 3], [4, 5, 6]],
      [[7, 8, 9], [10, 11, 12]]]]
```

<br />


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


```
x = [[[[1], [3]], [[9], [11]]],
     [[[2], [4]], [[10], [12]]],
     [[[5], [7]], [[13], [15]]],
     [[[6], [8]], [[14], [16]]]]
```

<br />


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


```
x = [[[[1],   [2],  [3],  [4]],
     [[5],   [6],  [7],  [8]],
     [[9],  [10], [11],  [12]],
     [[13], [14], [15],  [16]]]]
```

<br />


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


```
x = [[[[1], [3]]], [[[9], [11]]], [[[2], [4]]], [[[10], [12]]],
     [[[5], [7]]], [[[13], [15]]], [[[6], [8]]], [[[14], [16]]]]
```

<br />


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


```
x = [[[[1], [3]], [[5], [7]]],
     [[[2], [4]], [[10], [12]]],
     [[[5], [7]], [[13], [15]]],
     [[[6], [8]], [[14], [16]]]]
```

<br />

| ### Constructors and Destructors ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/batch-to-space#classtensorflow_1_1ops_1_1_batch_to_space_1a813bf5c031d4af21a394ba903c8dd8e7 (const :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/scope#classtensorflow_1_1_scope & scope, :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input input, :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/input#classtensorflow_1_1_input crops, int64 block_size) ` ||

| ### Public attributes ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/batch-to-space#classtensorflow_1_1ops_1_1_batch_to_space_1a4f9b292d9339c4c44142a6dcec013410 ` | ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/operation#classtensorflow_1_1_operation ` |
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/batch-to-space#classtensorflow_1_1ops_1_1_batch_to_space_1aacc62122ef498fc3a9ee89afdbcc6b74 ` | ` :: https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/output#classtensorflow_1_1_output ` |

| ### Public functions ||
|---|---|
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/batch-to-space#classtensorflow_1_1ops_1_1_batch_to_space_1a54c1c787b320c2f52099bc7bc02a85ed () const ` | ` ::tensorflow::Node * ` |
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/batch-to-space#classtensorflow_1_1ops_1_1_batch_to_space_1a23f9170b61d8e17feb37f1615a383de2 () const ` | ` ` |
| ` https://www.tensorflow.org/versions/r2.6/api_docs/cc/class/tensorflow/ops/batch-to-space#classtensorflow_1_1ops_1_1_batch_to_space_1a6e84c3b9b55d05ad30e6bcf376278c1d () const ` | ` ` |

## Public attributes

### operation

```
Operation operation
```

### output

```
::tensorflow::Output output
```

## Public functions

### BatchToSpace

```
 BatchToSpace(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  ::tensorflow::Input crops,
  int64 block_size
)
```

### node

```
::tensorflow::Node * node() const 
```

### operator::tensorflow::Input

```
 operator::tensorflow::Input() const 
```

### operator::tensorflow::Output

```
 operator::tensorflow::Output() const 
```