tensorflow::ops::SpaceToDepth

tensorflow::ops::SpaceToDepth

#include <array_ops.h>

SpaceToDepth for tensors of type T.

Summary

Rearranges blocks of spatial data, into depth. More specifically, this op outputs a copy of the input tensor where values from the height and width dimensions are moved to the depth dimension. The attr block_size indicates the input block size and how the data is moved.

  • Non-overlapping blocks of size block_size x block size are rearranged into depth at each location.
  • The depth of the output tensor is input_depth * block_size * block_size.
  • The input tensor's height and width must be divisible by block_size.

That is, assuming the input is in the shape: [batch, height, width, depth], the shape of the output will be: [batch, height/block_size, width/block_size, depth*block_size*block_size]

This operation requires that the input tensor be of rank 4, and that block_size be >=1 and a divisor of both the input height and width.

This operation is useful for resizing the activations between convolutions (but keeping all data), e.g. instead of pooling. It is also useful for training purely convolutional models.

For example, given this input of shape [1, 2, 2, 1], and block_size of 2:

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

This operation will output a tensor of shape [1, 1, 1, 4]:

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

Here, the input has a batch of 1 and each batch element has shape [2, 2, 1], the corresponding output will have a single element (i.e. width and height are both 1) and will have a depth of 4 channels (1 * block_size * block_size). The output element shape is [1, 1, 4].

For an input tensor with larger depth, here of shape [1, 2, 2, 3], e.g.

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

This operation, for block_size of 2, will return the following tensor of shape [1, 1, 1, 12]

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

Similarly, for the following input of shape [1 4 4 1], and a block size of 2:

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

the operator will return the following tensor of shape [1 2 2 4]:

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

Arguments:

  • scope: A Scope object
  • block_size: The size of the spatial block.

Returns:

Constructors and Destructors
SpaceToDepth(const ::tensorflow::Scope & scope, ::tensorflow::Input input, int64 block_size)
Public attributes
output
Public functions
node() const
::tensorflow::Node *
operator::tensorflow::Input() const
operator::tensorflow::Output() const

Public attributes

output

::tensorflow::Output output

Public functions

SpaceToDepth

 SpaceToDepth(
  const ::tensorflow::Scope & scope,
  ::tensorflow::Input input,
  int64 block_size
)

node

::tensorflow::Node * node() const 

operator::tensorflow::Input

operator::tensorflow::Input() const 

operator::tensorflow::Output

operator::tensorflow::Output() const 

© 2017 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/space-to-depth.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部