tensor.resize
#tensor.resize
Resizes the input tensor. In general, it calculates every value in the output tensor as a weighted average of neighborhood in the input tensor.
Args
self
(@Tensor<T>
) - The input tensor.roi
(Option<Tensor<T>>
) (optional) - 1-D tensor given as [start1, ..., startN, end1, ..., endN], where N is the rank of X or the length of axes, if provided. It only takes effect when coordinate_transformation_mode is "tf_crop_and_resize"scales
(Option<Tensor<T>>
) (optional) - The scale array along each dimension. It takes value greater than 0. If it's less than 1, it's sampling down, otherwise, it's upsampling. The number of elements of 'scales' should be the same as the rank of input 'X' or the length of 'axes', if provided. One and only one of 'scales' and 'sizes' MUST be specified.sizes
(Option<Tensor<usize>>
) (optional) - Target size of the output tensor. Its interpretation depends on the 'keep_aspect_ratio_policy' value. The number of elements of 'sizes' should be the same as the rank of input 'X', or the length of 'axes', if provided. One and only one of 'scales' and 'sizes' MUST be specified.antialias
(Option<usize>
) (default is 0) - If set to 1, "linear" and "cubic" interpolation modes will use an antialiasing filter when downscaling. Antialiasing is achieved by stretching the resampling filter by a factor max(1, 1 / scale).axes
(Option<Span<usize>>
) - If provided, it specifies a subset of axes that 'roi', 'scales' and 'sizes' refer to. If not provided, all axes are assumed [0, 1, ..., r-1], where r = rank(data).coordinate_transformation_mode
(Option<TRANSFORMATION_MODE>
) (default is half_pixel) - This attribute describes how to transform the coordinate in the resized tensor to the coordinate in the original tensor.cubic_coeff_a
(Option<T>
) (default is -0.75) - The coefficient 'a' used in cubic interpolation.exclude_outside
(Option<bool>
) (default is false) - If set to true, the weight of sampling locations outside the tensor will be set to 0 and the weight will be renormalized so that their sum is 1.0.extrapolation_value
(Option<T>
) (default is 0.0) - When coordinate_transformation_mode is "tf_crop_and_resize" and x_original is outside the range [0, length_original - 1], this value is used as the corresponding output value.keep_aspect_ratio_policy
(Option<KEEP_ASPECT_RATIO_POLICY>
) (default is stretch) - This attribute describes how to interpret thesizes
input with regard to keeping the original aspect ratio of the input, and it is not applicable when thescales
input is used.mode
(Option<MODE>
) (default is nearest) - Three interpolation modes: "nearest", "linear" and "cubic".nearest_mode
(Option<NEAREST_MODE>
) (default is round_prefer_floor) - Four modes: "round_prefer_floor" (as known as round half down), "round_prefer_ceil" (as known as round half up), "floor", "ceil". Only used by nearest interpolation.
Panics
Panics if both scales and sizes are
Option::None
.Panics if roi is
Option::None
for the coordinate_transformation_modetf_crop_and_resize
.Panics if antialias is not
Option::None
for modenearest
.
Returns
A new resized Tensor<T>
of the dimension given by output_dimension = floor(input_dimension * (roi_end - roi_start) * scale) is scale is specified, or output_size if size is specified (note that some value of the parameter keep_aspect_ratio_policy
can change sizes and therefore the dimension of the output tensor)
Example
Last updated