Skip to content

Commit

Permalink
spaceToBatchND doc fixes (tensorflow#1411)
Browse files Browse the repository at this point in the history
DOC
  • Loading branch information
jgartman authored and Nikhil Thorat committed Nov 26, 2018
1 parent 2da747a commit affd83c
Showing 1 changed file with 22 additions and 24 deletions.
46 changes: 22 additions & 24 deletions src/ops/array_ops.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,17 +817,17 @@ function batchToSpaceND_<T extends Tensor>(
}

/**
* This operation divides "spatial" dimensions [1, ..., M] of the input into
* a grid of blocks of shape block_shape, and interleaves these blocks with
* This operation divides "spatial" dimensions `[1, ..., M]` of the input into
* a grid of blocks of shape `blockShape`, and interleaves these blocks with
* the "batch" dimension (0) such that in the output, the spatial
* dimensions [1, ..., M] correspond to the position within the grid,
* dimensions `[1, ..., M]` correspond to the position within the grid,
* and the batch dimension combines both the position within a spatial block
* and the original batch position. Prior to division into blocks,
* the spatial dimensions of the input are optionally zero padded
* according to paddings. See below for a precise description.
* according to `paddings`. See below for a precise description.
*
* ```js
* const x = tf.tensor4d([1, 2, 3, 4], [4, 1, 1, 1]);
* const x = tf.tensor4d([1, 2, 3, 4], [1, 2, 2, 1]);
* const blockShape = [2, 2];
* const paddings = [[0, 0], [0, 0]];
*
Expand All @@ -836,33 +836,31 @@ function batchToSpaceND_<T extends Tensor>(
*
* @param x A `tf.Tensor`. N-D with `x.shape` = `[batch] + spatialShape +
* remainingShape`, where spatialShape has `M` dimensions.
* @param blockShape A 1-D array. Must be one of the following types: `int32`,
* `int64`. Must have shape `[M]`, all values must be >= 1.
* @param paddings A 2-D array. Must be one of the following types: `int32`,
* `int64`. Must have shape `[M, 2]`, all values must be >= 0. `paddings[i] =
* [padStart, padEnd]` specifies the amount to zero-pad from input dimension
* `i + 1`, which corresponds to spatial dimension `i`.
* It is required that
* @param blockShape A 1-D array. Must have shape `[M]`, all values must
* be >= 1.
* @param paddings A 2-D array. Must have shape `[M, 2]`, all values must be >=
* 0. `paddings[i] = [padStart, padEnd]` specifies the amount to zero-pad
* from input dimension `i + 1`, which corresponds to spatial dimension `i`. It
* is required that
* `(inputShape[i + 1] + padStart + padEnd) % blockShape[i] === 0`
*
* This operation is equivalent to the following steps:
*
* 1. Zero-pad the start and end of dimensions [1, ..., M] of the input
* according to paddings to produce padded of shape padded_shape.
* 1. Zero-pad the start and end of dimensions `[1, ..., M]` of the input
* according to `paddings` to produce `padded` of shape paddedShape.
*
* 2. Reshape padded to reshaped_padded of shape:
* [batch] + [padded_shape[1] / block_shape[0], block_shape[0], ...,
* padded_shape[M] / block_shape[M-1], block_shape[M-1]] + remaining_shape
* 2. Reshape `padded` to `reshapedPadded` of shape:
* `[batch] + [paddedShape[1] / blockShape[0], blockShape[0], ...,
* paddedShape[M] / blockShape[M-1], blockShape[M-1]] + remainingShape`
*
* 3. Permute dimensions of reshaped_padded to produce permuted_
* reshaped_padded of shape:
* block_shape + [batch] + [padded_shape[1] / block_shape[0], ...,
* padded_shape[M] / block_shape[M-1]] + remaining_shape
* 3. Permute dimensions of `reshapedPadded` to produce `permutedReshapedPadded`
* of shape: `blockShape + [batch] + [paddedShape[1] / blockShape[0], ...,
* paddedShape[M] / blockShape[M-1]] + remainingShape`
*
* 4. Reshape permuted_reshaped_padded to flatten block_shape into the
* 4. Reshape `permutedReshapedPadded` to flatten `blockShape` into the
* batch dimension, producing an output tensor of shape:
* [batch * prod(block_shape)] + [padded_shape[1] / block_shape[0], ...,
* padded_shape[M] / block_shape[M-1]] + remaining_shape
* `[batch * prod(blockShape)] + [paddedShape[1] / blockShape[0], ...,
* paddedShape[M] / blockShape[M-1]] + remainingShape`
*/
/** @doc {heading: 'Tensors', subheading: 'Transformations'} */
function spaceToBatchND_<T extends Tensor>(
Expand Down

0 comments on commit affd83c

Please sign in to comment.