Resize - 13 vs 18¶
- Resize13 → Resize18 +76 -38
Resize13 → Resize18
RENAMED
@@ -1 +1 @@
|
|
1
1
|
Resize the input tensor. In general, it calculates every value in the output tensor as a weighted average of neighborhood (a.k.a. sampling locations) in the input tensor.
|
2
|
-
Each dimension value of the output tensor is:
|
2
|
+
Each dimension value of the output tensor is: <br/>
|
3
|
-
output_dimension = floor(input_dimension * (roi_end - roi_start) * scale)
|
3
|
+
output_dimension = floor(input_dimension * (roi_end - roi_start) * scale) <br/>
|
4
|
+
if input "sizes" is not specified.
|
4
5
|
**Attributes**
|
6
|
+
* **antialias**:
|
7
|
+
If set to 1, "linear" and "cubic" interpolation modes will use an
|
8
|
+
antialiasing filter when downscaling. Antialiasing is achieved by
|
9
|
+
stretching the resampling filter by a factor max(1, 1 / scale),
|
10
|
+
which means that when downsampling, more input pixels contribute to
|
11
|
+
an output pixel.
|
12
|
+
* **axes**:
|
13
|
+
If provided, it specifies a subset of axes that 'roi', 'scales' and
|
14
|
+
'sizes' refer to. If not provided, all axes are assumed [0, 1, ...,
|
15
|
+
r-1], where r = rank(data). Non-specified dimensions are interpreted
|
16
|
+
as non-resizable. Negative value means counting dimensions from the
|
17
|
+
back. Accepted range is [-r, r-1], where r = rank(data). Behavior is
|
18
|
+
undefined if an axis is repeated.
|
5
19
|
* **coordinate_transformation_mode**:
|
6
20
|
This attribute describes how to transform the coordinate in the
|
7
21
|
resized tensor to the coordinate in the original tensor. <br/> The
|
8
22
|
coordinate of each dimension is transformed individually. Let's
|
9
23
|
describe a case using axis x as an example. Denote x_resized as the
|
10
24
|
coordinate of axis x in the resized tensor, x_original as the
|
11
|
-
coordinate of axis x in the original tensor, length_original as
|
25
|
+
coordinate of axis x in the original tensor, length_original as
|
12
|
-
length of the original tensor in axis x, length_resized as the
|
26
|
+
the length of the original tensor in axis x, length_resized as the
|
13
27
|
length of the resized tensor in axis x, roi_x = (start_x, end_x) of
|
14
|
-
the axis x in input "roi", scale = length_resized /
|
28
|
+
the axis x in input "roi", scale = length_resized /
|
29
|
+
length_original, <br/> if coordinate_transformation_mode is
|
30
|
+
"half_pixel", <br/> x_original = (x_resized + 0.5) / scale - 0.5
|
15
|
-
<br/> if coordinate_transformation_mode is "
|
31
|
+
<br/> if coordinate_transformation_mode is "pytorch_half_pixel",
|
16
|
-
x_original = (x_resized + 0.5) / scale - 0.5, <br/> if
|
17
|
-
coordinate_transformation_mode is "pytorch_half_pixel", <br/>
|
18
|
-
x_original = length_resized > 1 ? (x_resized + 0.5) / scale -
|
32
|
+
<br/> x_original = length_resized > 1 ? (x_resized + 0.5) / scale -
|
19
|
-
0
|
33
|
+
0.5 : 0 <br/> if coordinate_transformation_mode is
|
20
|
-
<br/> x_original = x_resized * (length_original
|
34
|
+
"align_corners", <br/> x_original = x_resized * (length_original
|
35
|
+
- 1) / (length_resized - 1) <br/> if
|
36
|
+
coordinate_transformation_mode is "asymmetric", <br/> x_original
|
21
|
-
|
37
|
+
= x_resized / scale <br/> if coordinate_transformation_mode is
|
38
|
+
"tf_crop_and_resize", <br/> x_original = length_resized > 1 ?
|
39
|
+
start_x * (length_original - 1) + x_resized * (end_x - start_x) *
|
40
|
+
(length_original - 1) / (length_resized - 1) : 0.5 * (start_x +
|
41
|
+
end_x) * (length_original - 1) .
|
22
|
-
"asymmetric", <br/> x_original = x_resized / scale, <br/> if
|
23
|
-
coordinate_transformation_mode is "tf_crop_and_resize", <br/>
|
24
|
-
x_original = length_resized > 1 ? start_x * (length_original - 1) +
|
25
|
-
x_resized * (end_x - start_x) * (length_original - 1) /
|
26
|
-
(length_resized - 1) : 0.5 * (start_x + end_x) * (length_original -
|
27
|
-
1).
|
28
42
|
* **cubic_coeff_a**:
|
29
43
|
The coefficient 'a' used in cubic interpolation. Two common choice
|
30
44
|
are -0.5 (in some cases of TensorFlow) and -0.75 (in PyTorch). Check
|
31
45
|
out Equation (4) in https://ieeexplore.ieee.org/document/1163711 for
|
32
|
-
the details. This attribute is valid only if
|
46
|
+
the details. This attribute is valid only if mode is "cubic".
|
33
47
|
* **exclude_outside**:
|
34
48
|
If set to 1, the weight of sampling locations outside the tensor
|
35
49
|
will be set to 0 and the weight will be renormalized so that their
|
36
50
|
sum is 1.0. The default value is 0.
|
37
51
|
* **extrapolation_value**:
|
38
52
|
When coordinate_transformation_mode is "tf_crop_and_resize" and
|
39
53
|
x_original is outside the range [0, length_original - 1], this value
|
40
54
|
is used as the corresponding output value. Default is 0.0f.
|
55
|
+
* **keep_aspect_ratio_policy**:
|
56
|
+
This attribute describes how to interpret the sizes input with
|
57
|
+
regard to keeping the original aspect ratio of the input, and it is
|
58
|
+
not applicable when the scales input is used. <br/> Given a set
|
59
|
+
of sizes, associated with a subset of axes (explicitly provided
|
60
|
+
or default), and assuming d = axes[i], with i being the index of
|
61
|
+
the provided sizes. <br/> If keep_aspect_ratio_policy is
|
62
|
+
"stretch", the original aspect ratio is disregarded, and the input
|
63
|
+
is resized to the specified size: <br/> out_size[d] = sizes[i]
|
64
|
+
<br/> If keep_aspect_ratio_policy is "not_larger", the sizes
|
65
|
+
are adjusted so that no extent of the output is larger than the
|
66
|
+
specified size, while keeping the original aspect ratio: <br/>
|
67
|
+
scale = Min(sizes[i] / in_size[d]) <br/> out_size[d] =
|
68
|
+
round_int(scale * in_size[i]) <br/> If keep_aspect_ratio_policy
|
69
|
+
is "not_smaller", the sizes are adjusted so that no extent of the
|
70
|
+
output is smaller than the specified size, while keeping the
|
71
|
+
original aspect ratio: <br/> scale = Max(sizes[i] / in_size[d])
|
72
|
+
<br/> out_size[d] = round_int(scale * in_size[i]) <br/> For non-
|
73
|
+
resizable axes (those not specified in axes), the output size will
|
74
|
+
be equal to the input size. Note: round_int stands for computing
|
75
|
+
the nearest integer value, rounding halfway cases up.
|
41
76
|
* **mode**:
|
42
|
-
Three interpolation modes: nearest (default), linear and
|
77
|
+
Three interpolation modes: "nearest" (default), "linear" and
|
43
|
-
"linear" mode includes linear interpolation for 1D
|
78
|
+
"cubic". The "linear" mode includes linear interpolation for 1D
|
44
|
-
N-linear interpolation for N-D tensor (for example,
|
79
|
+
tensor and N-linear interpolation for N-D tensor (for example,
|
45
|
-
interpolation for 2D tensor). The "cubic" mode includes
|
80
|
+
bilinear interpolation for 2D tensor). The "cubic" mode includes
|
46
|
-
interpolation for 1D tensor and N-cubic interpolation for N-D
|
81
|
+
cubic interpolation for 1D tensor and N-cubic interpolation for N-D
|
47
|
-
(for example, bicubic interpolation for 2D tensor).
|
82
|
+
tensor (for example, bicubic interpolation for 2D tensor).
|
48
83
|
* **nearest_mode**:
|
49
|
-
Four modes: round_prefer_floor (default, as known as round half
|
84
|
+
Four modes: "round_prefer_floor" (default, as known as round half
|
50
|
-
down), round_prefer_ceil (as known as round half up), floor,
|
85
|
+
down), "round_prefer_ceil" (as known as round half up), "floor",
|
51
|
-
Only used by nearest interpolation. It indicates how to get
|
86
|
+
"ceil". Only used by nearest interpolation. It indicates how to get
|
52
87
|
"nearest" pixel in input tensor from x_original, so this attribute
|
53
88
|
is valid only if "mode" is "nearest".
|
54
89
|
**Inputs**
|
55
90
|
Between 1 and 4 inputs.
|
56
91
|
* **X** (heterogeneous) - **T1**:
|
57
92
|
N-D tensor
|
58
93
|
* **roi** (optional, heterogeneous) - **T2**:
|
59
94
|
1-D tensor given as [start1, ..., startN, end1, ..., endN], where N
|
60
|
-
is the rank of X
|
95
|
+
is the rank of X or the length of axes, if provided. The RoIs'
|
61
|
-
coordinate system of the input
|
96
|
+
coordinates are normalized in the coordinate system of the input
|
97
|
+
image. It only takes effect when coordinate_transformation_mode is
|
62
|
-
|
98
|
+
"tf_crop_and_resize"
|
63
99
|
* **scales** (optional, heterogeneous) - **tensor(float)**:
|
64
100
|
The scale array along each dimension. It takes value greater than 0.
|
65
101
|
If it's less than 1, it's sampling down, otherwise, it's upsampling.
|
66
102
|
The number of elements of 'scales' should be the same as the rank of
|
67
|
-
input 'X'
|
103
|
+
input 'X' or the length of 'axes', if provided. One of 'scales' and
|
68
|
-
an error if both are specified.
|
104
|
+
'sizes' MUST be specified and it is an error if both are specified.
|
105
|
+
If 'sizes' is needed, the user can use an empty string as the name
|
69
|
-
|
106
|
+
of 'scales' in this operator's input list.
|
70
|
-
list.
|
71
107
|
* **sizes** (optional, heterogeneous) - **tensor(int64)**:
|
108
|
+
Target size of the output tensor. Its interpretation depends on the
|
72
|
-
|
109
|
+
'keep_aspect_ratio_policy' value.The number of elements of 'sizes'
|
73
|
-
should be the same as the rank of input 'X'
|
110
|
+
should be the same as the rank of input 'X', or the length of
|
74
|
-
and 'sizes' can be
|
111
|
+
'axes', if provided. Only one of 'scales' and 'sizes' can be
|
112
|
+
specified.
|
75
113
|
**Outputs**
|
76
114
|
* **Y** (heterogeneous) - **T1**:
|
77
115
|
N-D tensor after resizing
|
78
116
|
**Type Constraints**
|
79
117
|
* **T1** in (
|
80
118
|
tensor(bfloat16),
|
81
119
|
tensor(bool),
|
82
120
|
tensor(complex128),
|
83
121
|
tensor(complex64),
|
84
122
|
tensor(double),
|
85
123
|
tensor(float),
|
86
124
|
tensor(float16),
|
87
125
|
tensor(int16),
|
88
126
|
tensor(int32),
|
89
127
|
tensor(int64),
|
90
128
|
tensor(int8),
|
91
129
|
tensor(string),
|
92
130
|
tensor(uint16),
|
93
131
|
tensor(uint32),
|
94
132
|
tensor(uint64),
|
95
133
|
tensor(uint8)
|
96
134
|
):
|
97
135
|
Constrain input 'X' and output 'Y' to all tensor types.
|
98
136
|
* **T2** in (
|
99
137
|
tensor(double),
|
100
138
|
tensor(float),
|
101
139
|
tensor(float16)
|
102
140
|
):
|
103
141
|
Constrain roi type to float or double.
|