UNPKG

2.51 kBTypeScriptView Raw
1/**
2 * @license
3 * Copyright 2020 Google LLC. All Rights Reserved.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 * =============================================================================
16 */
17/// <amd-module name="@tensorflow/tfjs-core/dist/ops/depth_to_space" />
18import { Tensor4D } from '../tensor';
19import { TensorLike4D } from '../types';
20/**
21 * Rearranges data from depth into blocks of spatial data. More specifically,
22 * this op outputs a copy of the input tensor where values from the `depth`
23 * dimension are moved in spatial blocks to the `height` and `width` dimensions.
24 * The attr `blockSize` indicates the input block size and how the data is
25 * moved.
26 *
27 * - Chunks of data of size `blockSize * blockSize` from depth are rearranged
28 * into non-overlapping blocks of size `blockSize x blockSize`
29 *
30 * - The width the output tensor is `inputWidth * blockSize`, whereas the
31 * height is `inputHeight * blockSize`
32 *
33 * - The Y, X coordinates within each block of the output image are determined
34 * by the high order component of the input channel index
35 *
36 * - The depth of the input tensor must be divisible by `blockSize *
37 * blockSize`
38 *
39 * The `dataFormat` attr specifies the layout of the input and output tensors
40 * with the following options: "NHWC": [ `batch, height, width, channels` ]
41 * "NCHW": [ `batch, channels, height, width` ]
42 *
43 * ```js
44 * const x = tf.tensor4d([1, 2, 3, 4], [1, 1, 1, 4]);
45 * const blockSize = 2;
46 * const dataFormat = "NHWC";
47 *
48 * tf.depthToSpace(x, blockSize, dataFormat).print();
49 * ```
50 *
51 * @param x The input tensor of rank 4
52 * @param blockSIze An `int` that is `>= 2`. The size of the spatial block
53 * @param dataFormat An optional string from: "NHWC", "NCHW". Defaults to "NHWC"
54 *
55 * @doc {heading: 'Tensors', subheading: 'Transformations'}
56 */
57declare function depthToSpace_(x: Tensor4D | TensorLike4D, blockSize: number, dataFormat?: 'NHWC' | 'NCHW'): Tensor4D;
58export declare const depthToSpace: typeof depthToSpace_;
59export {};