Warning: This API is deprecated and will be removed in a future
version of TensorFlow after
the replacement is stable.
BatchToSpace
Stay organized with collections
Save and categorize content based on your preferences.
BatchToSpace for 4-D tensors of type T.
This is a legacy version of the more general BatchToSpaceND.
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.
Public Methods
Output<T>
|
asOutput()
Returns the symbolic handle of a tensor.
|
static
<T, U extends Number>
BatchToSpace<T>
|
create( Scope scope, Operand<T> input, Operand<U> crops, Long blockSize)
Factory method to create a class wrapping a new BatchToSpace operation.
|
Output<T>
|
output()
4-D with shape `[batch, height, width, depth]`, where:
height = height_pad - crop_top - crop_bottom
width = width_pad - crop_left - crop_right
The attr `block_size` must be greater than one.
|
Inherited Methods
From class
java.lang.Object
boolean
|
equals(Object arg0)
|
final
Class<?>
|
getClass()
|
int
|
hashCode()
|
final
void
|
notify()
|
final
void
|
notifyAll()
|
String
|
toString()
|
final
void
|
wait(long arg0, int arg1)
|
final
void
|
wait(long arg0)
|
final
void
|
wait()
|
Public Methods
public
Output<T>
asOutput
()
Returns the symbolic handle of a tensor.
Inputs to TensorFlow operations are outputs of another TensorFlow operation. This method is
used to obtain a symbolic handle that represents the computation of the input.
Factory method to create a class wrapping a new BatchToSpace operation.
Parameters
scope |
current scope |
input |
4-D tensor with shape
`[batchblock_sizeblock_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]] |
Returns
- a new instance of BatchToSpace
public
Output<T>
output
()
4-D with shape `[batch, height, width, depth]`, where:
height = height_pad - crop_top - crop_bottom
width = width_pad - crop_left - crop_right
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]]]]
The output tensor has shape `[1, 2, 2, 1]` and value:
x = [[[[1], [2]], [[3], [4]]]]
(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]]]]
The output tensor has shape `[1, 2, 2, 3]` and value:
x = [[[[1, 2, 3], [4, 5, 6]],
[[7, 8, 9], [10, 11, 12]]]]
(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]]]]
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]]]]
(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]]]]
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]]]]
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.
Last updated 2022-02-12 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 2022-02-12 UTC."],[],[],null,["# BatchToSpace\n\npublic final class **BatchToSpace** \nBatchToSpace for 4-D tensors of type T.\n\n\nThis is a legacy version of the more general BatchToSpaceND.\n\n\nRearranges (permutes) data from batch into blocks of spatial data, followed by\ncropping. This is the reverse transformation of SpaceToBatch. More specifically,\nthis op outputs a copy of the input tensor where values from the \\`batch\\`\ndimension are moved in spatial blocks to the \\`height\\` and \\`width\\` dimensions,\nfollowed by cropping along the \\`height\\` and \\`width\\` dimensions.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n### Public Methods\n\n|--------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [Output](/api_docs/java/org/tensorflow/Output)\\\u003cT\\\u003e | [asOutput](/api_docs/java/org/tensorflow/op/core/BatchToSpace#asOutput())() Returns the symbolic handle of a tensor. |\n| static \\\u003cT, U extends Number\\\u003e [BatchToSpace](/api_docs/java/org/tensorflow/op/core/BatchToSpace)\\\u003cT\\\u003e | [create](/api_docs/java/org/tensorflow/op/core/BatchToSpace#create(org.tensorflow.op.Scope,%20org.tensorflow.Operand\u003cT\u003e,%20org.tensorflow.Operand\u003cU\u003e,%20java.lang.Long))([Scope](/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e input, [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cU\\\u003e crops, Long blockSize) Factory method to create a class wrapping a new BatchToSpace operation. |\n| [Output](/api_docs/java/org/tensorflow/Output)\\\u003cT\\\u003e | [output](/api_docs/java/org/tensorflow/op/core/BatchToSpace#output())() 4-D with shape \\`\\[batch, height, width, depth\\]\\`, where: height = height_pad - crop_top - crop_bottom width = width_pad - crop_left - crop_right The attr \\`block_size\\` must be greater than one. \u003cbr /\u003e |\n\n### Inherited Methods\n\nFrom class [org.tensorflow.op.PrimitiveOp](/api_docs/java/org/tensorflow/op/PrimitiveOp) \n\n|------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------|\n| final boolean | [equals](/api_docs/java/org/tensorflow/op/PrimitiveOp#equals(java.lang.Object))(Object obj) |\n| final int | [hashCode](/api_docs/java/org/tensorflow/op/PrimitiveOp#hashCode())() |\n| [Operation](/api_docs/java/org/tensorflow/Operation) | [op](/api_docs/java/org/tensorflow/op/PrimitiveOp#op())() Returns the underlying [Operation](/api_docs/java/org/tensorflow/Operation) |\n| final String | [toString](/api_docs/java/org/tensorflow/op/PrimitiveOp#toString())() |\n\nFrom class java.lang.Object \n\n|------------------|---------------------------|\n| boolean | equals(Object arg0) |\n| final Class\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| String | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nFrom interface [org.tensorflow.Operand](/api_docs/java/org/tensorflow/Operand) \n\n|--------------------------------------------------------------|---------------------------------------------------------------------------------------------------------|\n| abstract [Output](/api_docs/java/org/tensorflow/Output)\\\u003cT\\\u003e | [asOutput](/api_docs/java/org/tensorflow/Operand#asOutput())() Returns the symbolic handle of a tensor. |\n\nPublic Methods\n--------------\n\n#### public [Output](/api_docs/java/org/tensorflow/Output)\\\u003cT\\\u003e\n**asOutput**\n()\n\nReturns the symbolic handle of a tensor.\n\nInputs to TensorFlow operations are outputs of another TensorFlow operation. This method is\nused to obtain a symbolic handle that represents the computation of the input.\n\n\u003cbr /\u003e\n\n#### public static [BatchToSpace](/api_docs/java/org/tensorflow/op/core/BatchToSpace)\\\u003cT\\\u003e\n**create**\n([Scope](/api_docs/java/org/tensorflow/op/Scope) scope, [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cT\\\u003e input, [Operand](/api_docs/java/org/tensorflow/Operand)\\\u003cU\\\u003e crops, Long blockSize)\n\nFactory method to create a class wrapping a new BatchToSpace operation. \n\n##### Parameters\n\n| scope | current scope |\n| 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\\`. |\n| 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\\]\\] |\n|-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n\n##### Returns\n\n- a new instance of BatchToSpace \n\n#### public [Output](/api_docs/java/org/tensorflow/Output)\\\u003cT\\\u003e\n**output**\n()\n\n4-D with shape \\`\\[batch, height, width, depth\\]\\`, where:\n\n\nheight = height_pad - crop_top - crop_bottom\nwidth = width_pad - crop_left - crop_right\n\n\nThe attr \\`block_size\\` must be greater than one. It indicates the block size.\n\n\nSome examples:\n\n\n(1) For the following input of shape \\`\\[4, 1, 1, 1\\]\\` and block_size of 2: \n\n [[[[1]]], [[[2]]], [[[3]]], [[[4]]]]\n \nThe output tensor has shape \\`\\[1, 2, 2, 1\\]\\` and value: \n\n x = [[[[1], [2]], [[3], [4]]]]\n \n(2) For the following input of shape \\`\\[4, 1, 1, 3\\]\\` and block_size of 2: \n\n [[[[1, 2, 3]]], [[[4, 5, 6]]], [[[7, 8, 9]]], [[[10, 11, 12]]]]\n \nThe output tensor has shape \\`\\[1, 2, 2, 3\\]\\` and value: \n\n x = [[[[1, 2, 3], [4, 5, 6]],\n [[7, 8, 9], [10, 11, 12]]]]\n \n(3) For the following input of shape \\`\\[4, 2, 2, 1\\]\\` and block_size of 2: \n\n x = [[[[1], [3]], [[9], [11]]],\n [[[2], [4]], [[10], [12]]],\n [[[5], [7]], [[13], [15]]],\n [[[6], [8]], [[14], [16]]]]\n \nThe output tensor has shape \\`\\[1, 4, 4, 1\\]\\` and value: \n\n x = [[[[1], [2], [3], [4]],\n [[5], [6], [7], [8]],\n [[9], [10], [11], [12]],\n [[13], [14], [15], [16]]]]\n \n(4) For the following input of shape \\`\\[8, 1, 2, 1\\]\\` and block_size of 2: \n\n x = [[[[1], [3]]], [[[9], [11]]], [[[2], [4]]], [[[10], [12]]],\n [[[5], [7]]], [[[13], [15]]], [[[6], [8]]], [[[14], [16]]]]\n \nThe output tensor has shape \\`\\[2, 2, 4, 1\\]\\` and value: \n\n x = [[[[1], [3]], [[5], [7]]],\n [[[2], [4]], [[10], [12]]],\n [[[5], [7]], [[13], [15]]],\n [[[6], [8]], [[14], [16]]]]\n \n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e"]]