tensorflow_mri.resize_with_crop_or_pad
tensorflow_mri.resize_with_crop_or_pad¶
- resize_with_crop_or_pad(tensor, shape, padding_mode='constant')[source]¶
Crops and/or pads a tensor to a target shape.
Pads symmetrically or crops centrally the input tensor as necessary to achieve the requested shape.
- Parameters
tensor – A
Tensor.shape – A
Tensor. The shape of the output tensor. The length ofshapemust be equal to or less than the rank oftensor. If the length ofshapeis less than the rank of tensor, the operation is applied along the lastlen(shape)dimensions oftensor. Any component ofshapecan be set to the special value -1 to leave the corresponding dimension unchanged.padding_mode – A str. Must be one of
'constant','reflect'or'symmetric'.
- Returns
A
Tensor. Has the same type astensor. The symmetrically padded/cropped tensor.