mindspore.nn.CentralCrop
- class mindspore.nn.CentralCrop(central_fraction)[source]
Crops the centeral region of the images with the central_fraction.
- Parameters
central_fraction (float) – Fraction of size to crop. It must be float and in range (0.0, 1.0].
- Inputs:
image (Tensor) - A 3-D tensor of shape [C, H, W], or a 4-D tensor of shape [N, C, H, W].
- Outputs:
Tensor, 3-D or 4-D float tensor, according to the input.
- Raises
TypeError – If central_fraction is not a float.
ValueError – If central_fraction is not in range (0, 1.0].
- Supported Platforms:
Ascend
GPU
CPU
Examples
>>> net = nn.CentralCrop(central_fraction=0.5) >>> image = Tensor(np.random.random((4, 3, 4, 4)), mindspore.float32) >>> output = net(image) >>> print(output.shape) (4, 3, 2, 2)