starling.samplers.ddpm_sampler.DDPMSampler
- class DDPMSampler[source]
Bases:
ModuleMethods
Initialize internal Module state, shared by both nn.Module and ScriptModule.
add_moduleAdd a child module to the current module.
applyApply
fnrecursively to every submodule (as returned by.children()) as well as self.bfloat16Casts all floating point parameters and buffers to
bfloat16datatype.buffersReturn an iterator over module buffers.
childrenReturn an iterator over immediate children modules.
compileCompile this Module's forward using
torch.compile().cpuMove all model parameters and buffers to the CPU.
cudaMove all model parameters and buffers to the GPU.
doubleCasts all floating point parameters and buffers to
doubledatatype.evalSet the module in evaluation mode.
extra_reprReturn the extra representation of the module.
floatCasts all floating point parameters and buffers to
floatdatatype.forwardDefine the computation performed at every call.
Generate labels to condition the generative process on.
get_bufferReturn the buffer given by
targetif it exists, otherwise throw an error.get_extra_stateReturn any extra state to include in the module's state_dict.
get_parameterReturn the parameter given by
targetif it exists, otherwise throw an error.get_submoduleReturn the submodule given by
targetif it exists, otherwise throw an error.halfCasts all floating point parameters and buffers to
halfdatatype.ipuMove all model parameters and buffers to the IPU.
load_state_dictCopy parameters and buffers from
state_dictinto this module and its descendants.modulesReturn an iterator over all modules in the network.
mtiaMove all model parameters and buffers to the MTIA.
named_buffersReturn an iterator over module buffers, yielding both the name of the buffer as well as the buffer itself.
named_childrenReturn an iterator over immediate children modules, yielding both the name of the module as well as the module itself.
named_modulesReturn an iterator over all modules in the network, yielding both the name of the module as well as the module itself.
named_parametersReturn an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself.
One denoising step of the diffusion model.
Sampling loop for the diffusion model.
parametersReturn an iterator over module parameters.
register_backward_hookRegister a backward hook on the module.
register_bufferAdd a buffer to the module.
register_forward_hookRegister a forward hook on the module.
register_forward_pre_hookRegister a forward pre-hook on the module.
register_full_backward_hookRegister a backward hook on the module.
register_full_backward_pre_hookRegister a backward pre-hook on the module.
register_load_state_dict_post_hookRegister a post-hook to be run after module's
load_state_dict()is called.register_load_state_dict_pre_hookRegister a pre-hook to be run before module's
load_state_dict()is called.register_moduleAlias for
add_module().register_parameterAdd a parameter to the module.
register_state_dict_post_hookRegister a post-hook for the
state_dict()method.register_state_dict_pre_hookRegister a pre-hook for the
state_dict()method.requires_grad_Change if autograd should record operations on parameters in this module.
Sample conformations from the trained diffusion model.
set_extra_stateSet extra state contained in the loaded state_dict.
set_submoduleSet the submodule given by
targetif it exists, otherwise throw an error.share_memorystate_dictReturn a dictionary containing references to the whole state of the module.
toMove and/or cast the parameters and buffers.
to_emptyMove the parameters and buffers to the specified device without copying storage.
trainSet the module in training mode.
typeCasts all parameters and buffers to
dst_type.xpuMove all model parameters and buffers to the XPU.
zero_gradReset gradients of all model parameters.
Attributes
T_destinationcall_super_initdump_patchestraining- __init__(ddpm_model, encoder_model, ionic_strength=150)[source]
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- generate_labels(labels: str) Tensor[source]
Generate labels to condition the generative process on.
- Parameters:
labels (str) – A sequence to generate labels from.
- Returns:
The labels to condition the generative process on.
- Return type:
- p_sample(x: Tensor, timestamp: int, labels: Tensor, attention_mask: Tensor) Tensor[source]
One denoising step of the diffusion model. This function is used in p_sample_loop to denoise the initial tensor sampled from N(0, I)
- Parameters:
x (torch.Tensor) – A tensor to denoise
timestamp (int) – The timestep of the denoising-diffusion process to denoise
labels (torch.Tensor) – Labels (sequences) to condition the model on
- Returns:
Returns the denoised tensor (t-1)
- Return type:
- p_sample_loop(shape: tuple, labels: Tensor, return_all_timesteps: bool = False, constraint=None) Tensor[source]
Sampling loop for the diffusion model. It loops over the timesteps to denoise the initial tensor sampled from N(0, I)
- Parameters:
shape (tuple) – The shape of the tensor to sample from N(0, I)
labels (torch.Tensor) – Labels to condition the sampling on
steps (int, optional) – Number of steps to sample, by default None (all timesteps)
return_all_timesteps (bool, optional) – Whether to return the full trajectory of denoising, by default False
- Returns:
Returns the fully denoised tensor, in this case a latent space that can be decoded using a pre-trained VAE
- Return type:
- sample(num_conformations: int, labels: Tensor, show_per_step_progress_bar: bool = True, batch_count: int = 1, max_batch_count: int = 1, return_all_timesteps: bool = False, constraint=None) Tensor[source]
Sample conformations from the trained diffusion model.
- Parameters:
- Returns:
Distance map representing protein conformations
- Return type: