Skip to content

Commit affd83c

Browse files
jgartmanNikhil Thorat
authored andcommitted
spaceToBatchND doc fixes (tensorflow#1411)
DOC
1 parent 2da747a commit affd83c

File tree

1 file changed

+22
-24
lines changed

1 file changed

+22
-24
lines changed

src/ops/array_ops.ts

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -817,17 +817,17 @@ function batchToSpaceND_<T extends Tensor>(
817817
}
818818

819819
/**
820-
* This operation divides "spatial" dimensions [1, ..., M] of the input into
821-
* a grid of blocks of shape block_shape, and interleaves these blocks with
820+
* This operation divides "spatial" dimensions `[1, ..., M]` of the input into
821+
* a grid of blocks of shape `blockShape`, and interleaves these blocks with
822822
* the "batch" dimension (0) such that in the output, the spatial
823-
* dimensions [1, ..., M] correspond to the position within the grid,
823+
* dimensions `[1, ..., M]` correspond to the position within the grid,
824824
* and the batch dimension combines both the position within a spatial block
825825
* and the original batch position. Prior to division into blocks,
826826
* the spatial dimensions of the input are optionally zero padded
827-
* according to paddings. See below for a precise description.
827+
* according to `paddings`. See below for a precise description.
828828
*
829829
* ```js
830-
* const x = tf.tensor4d([1, 2, 3, 4], [4, 1, 1, 1]);
830+
* const x = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]);
831831
* const blockShape = [2, 2];
832832
* const paddings = [[0, 0], [0, 0]];
833833
*
@@ -836,33 +836,31 @@ function batchToSpaceND_<T extends Tensor>(
836836
*
837837
* @param x A `tf.Tensor`. N-D with `x.shape` = `[batch] + spatialShape +
838838
* remainingShape`, where spatialShape has `M` dimensions.
839-
* @param blockShape A 1-D array. Must be one of the following types: `int32`,
840-
* `int64`. Must have shape `[M]`, all values must be >= 1.
841-
* @param paddings A 2-D array. Must be one of the following types: `int32`,
842-
* `int64`. Must have shape `[M, 2]`, all values must be >= 0. `paddings[i] =
843-
* [padStart, padEnd]` specifies the amount to zero-pad from input dimension
844-
* `i + 1`, which corresponds to spatial dimension `i`.
845-
* It is required that
839+
* @param blockShape A 1-D array. Must have shape `[M]`, all values must
840+
* be >= 1.
841+
* @param paddings A 2-D array. Must have shape `[M, 2]`, all values must be >=
842+
* 0. `paddings[i] = [padStart, padEnd]` specifies the amount to zero-pad
843+
* from input dimension `i + 1`, which corresponds to spatial dimension `i`. It
844+
* is required that
846845
* `(inputShape[i + 1] + padStart + padEnd) % blockShape[i] === 0`
847846
*
848847
* This operation is equivalent to the following steps:
849848
*
850-
* 1. Zero-pad the start and end of dimensions [1, ..., M] of the input
851-
* according to paddings to produce padded of shape padded_shape.
849+
* 1. Zero-pad the start and end of dimensions `[1, ..., M]` of the input
850+
* according to `paddings` to produce `padded` of shape paddedShape.
852851
*
853-
* 2. Reshape padded to reshaped_padded of shape:
854-
* [batch] + [padded_shape[1] / block_shape[0], block_shape[0], ...,
855-
* padded_shape[M] / block_shape[M-1], block_shape[M-1]] + remaining_shape
852+
* 2. Reshape `padded` to `reshapedPadded` of shape:
853+
* `[batch] + [paddedShape[1] / blockShape[0], blockShape[0], ...,
854+
* paddedShape[M] / blockShape[M-1], blockShape[M-1]] + remainingShape`
856855
*
857-
* 3. Permute dimensions of reshaped_padded to produce permuted_
858-
* reshaped_padded of shape:
859-
* block_shape + [batch] + [padded_shape[1] / block_shape[0], ...,
860-
* padded_shape[M] / block_shape[M-1]] + remaining_shape
856+
* 3. Permute dimensions of `reshapedPadded` to produce `permutedReshapedPadded`
857+
* of shape: `blockShape + [batch] + [paddedShape[1] / blockShape[0], ...,
858+
* paddedShape[M] / blockShape[M-1]] + remainingShape`
861859
*
862-
* 4. Reshape permuted_reshaped_padded to flatten block_shape into the
860+
* 4. Reshape `permutedReshapedPadded` to flatten `blockShape` into the
863861
* batch dimension, producing an output tensor of shape:
864-
* [batch * prod(block_shape)] + [padded_shape[1] / block_shape[0], ...,
865-
* padded_shape[M] / block_shape[M-1]] + remaining_shape
862+
* `[batch * prod(blockShape)] + [paddedShape[1] / blockShape[0], ...,
863+
* paddedShape[M] / blockShape[M-1]] + remainingShape`
866864
*/
867865
/** @doc {heading: 'Tensors', subheading: 'Transformations'} */
868866
function spaceToBatchND_<T extends Tensor>(

0 commit comments

Comments
 (0)