Mattergen / data /mattergen /diffusion /discrete_time.py
introvoyz041's picture
Migrated from GitHub
cfeea40 verified
raw
history blame contribute delete
426 Bytes
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
import torch
def to_discrete_time(t: torch.Tensor, N: int, T: float) -> torch.LongTensor:
"""Convert continuous time to integer timestep.
Args:
t: continuous time between 0 and T
N: number of timesteps
T: max time
Returns:
Integer timesteps between 0 and N-1
"""
return ((t * (N - 1)) / T).long()