Randomly rotate the input arrays. This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic ` for more information. Args: range_x: Range of rotation angle in radians in the plane defined by the first and second axes. If si
| 1302 | |
| 1303 | |
| 1304 | class RandRotate(RandomizableTransform, InvertibleTransform, LazyTransform): |
| 1305 | """ |
| 1306 | Randomly rotate the input arrays. |
| 1307 | |
| 1308 | This transform is capable of lazy execution. See the :ref:`Lazy Resampling topic<lazy_resampling>` |
| 1309 | for more information. |
| 1310 | |
| 1311 | Args: |
| 1312 | range_x: Range of rotation angle in radians in the plane defined by the first and second axes. |
| 1313 | If single number, angle is uniformly sampled from (-range_x, range_x). |
| 1314 | range_y: Range of rotation angle in radians in the plane defined by the first and third axes. |
| 1315 | If single number, angle is uniformly sampled from (-range_y, range_y). only work for 3D data. |
| 1316 | range_z: Range of rotation angle in radians in the plane defined by the second and third axes. |
| 1317 | If single number, angle is uniformly sampled from (-range_z, range_z). only work for 3D data. |
| 1318 | prob: Probability of rotation. |
| 1319 | keep_size: If it is False, the output shape is adapted so that the |
| 1320 | input array is contained completely in the output. |
| 1321 | If it is True, the output shape is the same as the input. Default is True. |
| 1322 | mode: {``"bilinear"``, ``"nearest"``} |
| 1323 | Interpolation mode to calculate output values. Defaults to ``"bilinear"``. |
| 1324 | See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html |
| 1325 | padding_mode: {``"zeros"``, ``"border"``, ``"reflection"``} |
| 1326 | Padding mode for outside grid values. Defaults to ``"border"``. |
| 1327 | See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html |
| 1328 | align_corners: Defaults to False. |
| 1329 | See also: https://pytorch.org/docs/stable/generated/torch.nn.functional.grid_sample.html |
| 1330 | dtype: data type for resampling computation. Defaults to ``float32``. |
| 1331 | If None, use the data type of input data. To be compatible with other modules, |
| 1332 | the output data type is always ``float32``. |
| 1333 | lazy: a flag to indicate whether this transform should execute lazily or not. |
| 1334 | Defaults to False |
| 1335 | """ |
| 1336 | |
| 1337 | backend = Rotate.backend |
| 1338 | |
| 1339 | def __init__( |
| 1340 | self, |
| 1341 | range_x: tuple[float, float] | float = 0.0, |
| 1342 | range_y: tuple[float, float] | float = 0.0, |
| 1343 | range_z: tuple[float, float] | float = 0.0, |
| 1344 | prob: float = 0.1, |
| 1345 | keep_size: bool = True, |
| 1346 | mode: str = GridSampleMode.BILINEAR, |
| 1347 | padding_mode: str = GridSamplePadMode.BORDER, |
| 1348 | align_corners: bool = False, |
| 1349 | dtype: DtypeLike | torch.dtype = np.float32, |
| 1350 | lazy: bool = False, |
| 1351 | ) -> None: |
| 1352 | RandomizableTransform.__init__(self, prob) |
| 1353 | LazyTransform.__init__(self, lazy=lazy) |
| 1354 | self.range_x = ensure_tuple(range_x) |
| 1355 | if len(self.range_x) == 1: |
| 1356 | self.range_x = tuple(sorted([-self.range_x[0], self.range_x[0]])) |
| 1357 | self.range_y = ensure_tuple(range_y) |
| 1358 | if len(self.range_y) == 1: |
| 1359 | self.range_y = tuple(sorted([-self.range_y[0], self.range_y[0]])) |
| 1360 | self.range_z = ensure_tuple(range_z) |
| 1361 | if len(self.range_z) == 1: |
no outgoing calls
searching dependent graphs…