-
Notifications
You must be signed in to change notification settings - Fork 1.5k
RandAffine cannot return same transform when randomize param set to False. #4303
Copy link
Copy link
Closed
Description
Describe the bug
RandAffine cannot return same transform when randomize param set to False.
To Reproduce
Steps to reproduce the behavior:
from monai.transforms.spatial.array import RandAffine
rand_affine = RandAffine(
prob=1,
rotate_range=(np.pi/6, 0, 0),
translate_range=((-2, 2),(-2, 2),(-2, 2)),
scale_range=((-0.1,0.1),(-0.1, 0.1),(-0.1,0.1)),
spatial_size=(16,16,16),
cache_grid=True,
padding_mode = "zeros"
)
arr = torch.randn((1, 16,16,16))*100
rand_affine.randomize(None)
arr1 = rand_affine(arr ,randomize=False)
m1 = rand_affine.rand_affine_grid.get_transformation_matrix()
print(m1)
arr2 = rand_affine(arr, randomize=False)
m1 = rand_affine.rand_affine_grid.get_transformation_matrix()
print(m1)
print(torch.sum(arr1-arr2))Expected behavior
when randomize=False, return the same result.
Environment
Ensuring you use the relevant python executable, please paste the output of:
python -c 'import monai; monai.config.print_debug_info()'
================================
Printing MONAI config...
================================
MONAI version: 0.8.1+257.g6eaa3ab1.dirty
Numpy version: 1.21.6
Pytorch version: 1.11.0
MONAI flags: HAS_EXT = True, USE_COMPILED = False
MONAI rev id: 6eaa3ab1b0f5ba568d69785cefbdb1cde74d259a
MONAI __file__: /ssd/libs/MONAI/MONAI/monai/__init__.py
Optional dependencies:
Pytorch Ignite version: NOT INSTALLED or UNKNOWN VERSION.
Nibabel version: NOT INSTALLED or UNKNOWN VERSION.
scikit-image version: 0.19.2
Pillow version: 9.1.1
Tensorboard version: NOT INSTALLED or UNKNOWN VERSION.
gdown version: NOT INSTALLED or UNKNOWN VERSION.
TorchVision version: NOT INSTALLED or UNKNOWN VERSION.
tqdm version: NOT INSTALLED or UNKNOWN VERSION.
lmdb version: NOT INSTALLED or UNKNOWN VERSION.
psutil version: 5.9.0
pandas version: 1.4.2
einops version: NOT INSTALLED or UNKNOWN VERSION.
transformers version: NOT INSTALLED or UNKNOWN VERSION.
mlflow version: NOT INSTALLED or UNKNOWN VERSION.
pynrrd version: NOT INSTALLED or UNKNOWN VERSION.
For details about installing the optional dependencies, please visit:
https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies
Additional context
Add any other context about the problem here.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels

