agedi.diffusion.distributions.normal¶
Attributes¶
Classes¶
Standard Normal Distribution |
|
Normal Distribution |
|
Truncated Normal Distribution |
|
Normal distribution whose noise increment has zero center of mass per graph. |
|
Standard Normal distribution with zero center of mass per graph. |
Functions¶
|
Subtract the per-graph center of mass from x. |
Module Contents¶
- agedi.diffusion.distributions.normal._zero_com(x: torch.Tensor, batch_idx: torch.Tensor) torch.Tensor¶
Subtract the per-graph center of mass from x.
Projects x onto the zero-COM subspace: each graph’s mean column is subtracted so that the COM of the returned tensor is exactly zero for every graph. This is the translational-invariance projection from the EDM paper (Hoogeboom et al., NeurIPS 2022, arXiv:2203.17003).
- Parameters:
x (torch.Tensor, shape (n_atoms, d))
batch_idx (torch.Tensor, shape (n_atoms,)) – Graph membership index (
batch.batch).
- Return type:
torch.Tensor, shape (n_atoms, d)
- agedi.diffusion.distributions.normal._CONFINEMENT_CLAMP_EPS = 0.0001¶
- class agedi.diffusion.distributions.normal.StandardNormal(scale: float = 1.0, **kwargs)¶
Bases:
agedi.diffusion.distributions.DistributionStandard Normal Distribution
- Parameters:
scale (float, optional) – Standard deviation used when sampling. Defaults to
1.0. Set this to the SDE’ssigma_max(orsqrt(var(t=1))) so that the prior matches the forward-process marginal at T=1, replacing the old0.8 * N**(1/3)heuristic which was arbitrary and broke for non-compact or heterogeneously-sized systems.
- scale = 1.0¶
- get_hparams() dict¶
Return hyperparameters for this distribution.
- _setup(batch: agedi.data.AtomsGraph) None¶
Prepare the distribution for sampling from batch.
Sets
self.shapeto(n_atoms, *trailing)wheren_atomsis read frombatch.n_atomsand the trailing dimensions come from the existing attribute. Usingn_atomsrather than the attribute’s leading dimension avoids a shape-mismatch when called during graph initialisation (viainitialize_graph()), where the attribute tensor may still be empty even thoughn_atomshas already been set.- Parameters:
batch (AtomsGraph) – Batch of atomistic data.
- _sample(shape: torch.Size | None = None, **kwargs) torch.Tensor¶
Sample from the standard normal distribution.
- Parameters:
shape (torch.Size, optional) – Output shape. Defaults to
self.shapeset during_setup.- Returns:
Sampled tensor with std equal to
self.scale.- Return type:
torch.Tensor
- class agedi.diffusion.distributions.normal.Normal¶
Bases:
agedi.diffusion.distributions.DistributionNormal Distribution
- _sample(mu: torch.Tensor, sigma: torch.Tensor, **kwargs) torch.Tensor¶
Sample from the normal distribution
- Parameters:
mu (torch.Tensor) – Mean of the distribution
sigma (torch.Tensor) – Standard deviation of the distribution
- Returns:
Sampled tensor
- Return type:
torch.Tensor
- class agedi.diffusion.distributions.normal.TruncatedNormal(index: int = 2, **kwargs)¶
Bases:
agedi.diffusion.distributions.DistributionTruncated Normal Distribution
- Parameters:
index (int) – The index of the property to truncate
- index = 2¶
- get_hparams() Dict¶
Return hyperparameters for this distribution.
- _setup(batch: agedi.data.AtomsGraph) None¶
Setup the distribution
Prepare the distribution for sampling of the batch
- Parameters:
batch (AtomsGraph) – Batch of data
- Return type:
None
- _sample(mu: torch.Tensor, sigma: torch.Tensor, **kwargs) torch.Tensor¶
Sample from the truncated normal distribution
- Parameters:
mu (torch.Tensor) – Mean of the distribution
sigma (torch.Tensor) – Standard deviation of the distribution
- Returns:
Sampled tensor
- Return type:
torch.Tensor
- class agedi.diffusion.distributions.normal.ZeroComNormal¶
Bases:
NormalNormal distribution whose noise increment has zero center of mass per graph.
Drop-in replacement for
Normalfor use with thePositionsnoiser on gas-phase molecules and clusters. After samplingx = N(mu, sigma), the COM of the noise increment(x - mu)is subtracted per graph so that the diffusion process operates in the translationally-invariant subspace.Reference: Hoogeboom et al., “Equivariant Diffusion for Molecule Generation in 3D”, NeurIPS 2022. arXiv:2203.17003
- _setup(batch: agedi.data.AtomsGraph) None¶
- _sample(mu: torch.Tensor, sigma: torch.Tensor, **kwargs) torch.Tensor¶
Sample from the normal distribution
- Parameters:
mu (torch.Tensor) – Mean of the distribution
sigma (torch.Tensor) – Standard deviation of the distribution
- Returns:
Sampled tensor
- Return type:
torch.Tensor
- class agedi.diffusion.distributions.normal.ZeroComStandardNormal(scale: float = 1.0, **kwargs)¶
Bases:
StandardNormalStandard Normal distribution with zero center of mass per graph.
Drop-in replacement for
StandardNormalintended as the prior distribution for thePositionsnoiser. Sampled positions are centered at the origin for every graph.- Parameters:
scale (float, optional) – Standard deviation of the prior. Should be set to
sqrt(sde.var(t=1))(i.e.sigma_maxfor a VE-SDE) so that the prior matches the forward-process marginal at T=1. Defaults to1.0;Positionssets this automatically from the SDE.Reference (Hoogeboom et al., "Equivariant Diffusion for Molecule Generation)
3D" (in)
arXiv (NeurIPS 2022.)
- _setup(batch: agedi.data.AtomsGraph) None¶
Prepare the distribution for sampling from batch.
Sets
self.shapeto(n_atoms, *trailing)wheren_atomsis read frombatch.n_atomsand the trailing dimensions come from the existing attribute. Usingn_atomsrather than the attribute’s leading dimension avoids a shape-mismatch when called during graph initialisation (viainitialize_graph()), where the attribute tensor may still be empty even thoughn_atomshas already been set.- Parameters:
batch (AtomsGraph) – Batch of atomistic data.
- _sample(shape: torch.Size | None = None, **kwargs) torch.Tensor¶
Sample from the standard normal distribution.
- Parameters:
shape (torch.Size, optional) – Output shape. Defaults to
self.shapeset during_setup.- Returns:
Sampled tensor with std equal to
self.scale.- Return type:
torch.Tensor