return output shape of conv2d or pooling, ! borrow from onnx Args: auto_pad: string input_spatial_shape: list[int] kernel_spatial_shape: list[int] strides_spatial: list[int] output_spatial_shape: list[int] Returns: list[int
(auto_pad, input_spatial_shape, kernel_spatial_shape,
strides_spatial)
| 187 | |
| 188 | |
| 189 | def get_output_shape(auto_pad, input_spatial_shape, kernel_spatial_shape, |
| 190 | strides_spatial): |
| 191 | """ |
| 192 | return output shape of conv2d or pooling, |
| 193 | ! borrow from onnx |
| 194 | Args: |
| 195 | auto_pad: string |
| 196 | input_spatial_shape: list[int] |
| 197 | kernel_spatial_shape: list[int] |
| 198 | strides_spatial: list[int] |
| 199 | output_spatial_shape: list[int] |
| 200 | Returns: |
| 201 | list[int |
| 202 | """ |
| 203 | out_shape = [0] * len(input_spatial_shape) |
| 204 | if auto_pad in ('SAME_UPPER', 'SAME_LOWER'): |
| 205 | for i in range(len(input_spatial_shape)): |
| 206 | out_shape[i] = int( |
| 207 | np.ceil( |
| 208 | float(input_spatial_shape[i]) / float(strides_spatial[i]))) |
| 209 | elif auto_pad == 'VALID': |
| 210 | for i in range(len(input_spatial_shape)): |
| 211 | out_shape[i] = int( |
| 212 | np.ceil( |
| 213 | float(input_spatial_shape[i] - |
| 214 | (kernel_spatial_shape[i] - 1)) / |
| 215 | float(strides_spatial[i]))) |
| 216 | return out_shape |
| 217 | |
| 218 | |
| 219 | def force_unicode(s): |