Document feedback

Question document fragment

When a question document fragment contains a formula, it is displayed as a space.

Submission type
issue

It's a little complicated...

I'd like to ask someone.

Please select the submission type

Problem type
Specifications and Common Mistakes

- Specifications and Common Mistakes:

- Misspellings or punctuation mistakes,incorrect formulas, abnormal display.

- Incorrect links, empty cells, or wrong formats.

- Chinese characters in English context.

- Minor inconsistencies between the UI and descriptions.

- Low writing fluency that does not affect understanding.

- Incorrect version numbers, including software package names and version numbers on the UI.

Usability

- Usability:

- Incorrect or missing key steps.

- Missing main function descriptions, keyword explanation, necessary prerequisites, or precautions.

- Ambiguous descriptions, unclear reference, or contradictory context.

- Unclear logic, such as missing classifications, items, and steps.

Correctness

- Correctness:

- Technical principles, function descriptions, supported platforms, parameter types, or exceptions inconsistent with that of software implementation.

- Incorrect schematic or architecture diagrams.

- Incorrect commands or command parameters.

- Incorrect code.

- Commands inconsistent with the functions.

- Wrong screenshots.

- Sample code running error, or running results inconsistent with the expectation.

Risk Warnings

- Risk Warnings:

- Lack of risk warnings for operations that may damage the system or important data.

Content Compliance

- Content Compliance:

- Contents that may violate applicable laws and regulations or geo-cultural context-sensitive words and expressions.

- Copyright infringement.

Please select the type of question

Problem description

Describe the bug so that we can quickly locate the problem.

mindspore.ops.space_to_batch_nd

mindspore.ops.space_to_batch_nd(input_x, block_size, paddings)[source]

Divides a tensor’s spatial dimensions into blocks and combines the block sizes with the original batch.

This operation will divide spatial dimensions into blocks with block_size, and after division, the output tensor’s spatial dimension is the corresponding number of blocks. The output tensor’s batch dimension is the product of the original batch and the product of block_size. Before division, the spatial dimensions of the input are zero padded according to paddings if necessary. Assume input shape is (n,c1,...ck,w1,...,wM), then the shape of the output tensor will be (n,c1,...ck,w1,...,wM), where

n=n(block_size[0]...block_size[M])wi=(wi+paddings[i][0]+paddings[i][1])//block_size[i]
Parameters
  • input_x (Tensor) – The input tensor. It must be a 4-D tensor on Ascend.

  • block_size (Union[list(int), tuple(int), int]) – The block size of dividing block with all value greater than 1. If block_size is a tuple or list, the length of block_size is M corresponding to the number of spatial dimensions. If block_size is an int, the block size of M dimensions are the same, equal to block_size. M must be 2 on Ascend.

  • paddings (Union[tuple, list]) – The padding values for spatial dimensions, containing M subtraction list. Each contains 2 integer values. All values must be greater than 0. paddings[i] specifies the paddings for the spatial dimension i, which corresponds to the input dimension i + offset. It is required that input_shape[i+offset]+paddings[i][0]+paddings[i][1] is divisible by block_size[i]. M must be 2 on Ascend.

Returns

Tensor, the output tensor with the same data type as input.

Raises
  • ValueError – If block_size is not one dimensional when block_size is a list or tuple.

  • ValueError – If the length of block_size is not 2 on Ascend.

  • ValueError – If the element of block_size is not an integer larger than 1.

  • ValueError – If shape of paddings is not (M, 2), where M is the length of block_size.

  • ValueError – If the element of paddings is not an integer larger than 0.

  • TypeError – If block_size is not one of list, tuple, int.

  • TypeError – If paddings is neither list nor tuple.

Supported Platforms:

Ascend GPU CPU

Examples

>>> block_size = [2, 2]
>>> paddings = [[0, 0], [0, 0]]
>>> input_x = Tensor(np.array([[[[1, 2], [3, 4]]]]), mindspore.float32)
>>> output = ops.space_to_batch_nd(input_x, block_size, paddings)
>>> print(output)
[[[[1.]]]
 [[[2.]]]
 [[[3.]]]
 [[[4.]]]]