-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
I am reading the source code implementation of DDPM and DDIM schedulers, and I found this line defining timesteps for the schedulers timesteps = (np.arange(0, num_inference_steps) * step_ratio).round()[::-1].astype(np.int64)
np.arange(0, 100) doesn't return an array from 0 to 1000, it actually returns an array from 0 to 999. Therefore, if we have, say, step_ratio = 10, and num_inference_steps=100 for a model trained on DDPM of num_train_timesteps=1000, then the final self.timesteps would be a 1D array from 990 to 0, NOT 1000 to 0.
I think the right one is: timesteps = (np.arange(0, num_inference_steps + 1e-3) * step_ratio).round()[::-1].astype(np.int64)
Here's the links for the schedulers:
- DDPM:
MONAI/monai/networks/schedulers/ddpm.py
Line 128 in 69f3dd2
timesteps = (np.arange(0, num_inference_steps) * step_ratio).round()[::-1].astype(np.int64) - DDIM:
MONAI/monai/networks/schedulers/ddim.py
Line 130 in 69f3dd2
timesteps = (np.arange(0, num_inference_steps) * step_ratio).round()[::-1].copy().astype(np.int64)