starling.models.unet.UNetConditional
- class UNetConditional[source]
Bases:
ModuleMethods
A U-Net architecture that uses ResNet blocks with spatial transformer blocks to process the input tensor and the context data (protein sequences).
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.Forward pass of the UNet architecture.
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.
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.
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__(in_channels: int, out_channels: int, base: int, norm: str, blocks: List = [2, 2, 2], middle_blocks: int = 2, labels_dim: int = 512, sinusoidal_pos_emb_theta: int = 10000)[source]
A U-Net architecture that uses ResNet blocks with spatial transformer blocks to process the input tensor and the context data (protein sequences). The U-Net architecture consists of an encoder, a middle section, and a decoder. The spatial transformer blocks are used to capture the relationships between the input tensor and the context data (in our case protein sequences).
- Parameters:
in_channels (int) – The number of features in the input tensor.
out_channels (int) – The number of features in the output tensor.
base (int) – The base number of features in the U-Net architecture.
norm (str) – The normalization layer to be used in the block. Choose from batch, instance, rms, or group
blocks (List, optional) – The number of ResNet + spatial transformer blocks in each section of the U-Net architecture, by default [2, 2, 2]
middle_blocks (int, optional) – The number of ResNet + spatial transformer blocks in the middle section of the U-Net architecture, by default 2
labels_dim (int, optional) – The dimension of the context data (i.e., protein sequences), by default 512
sinusoidal_pos_emb_theta (int, optional) – A scaling factor for the positional (timestep) embeddings, by default 10000
- forward(x: Tensor, time: Tensor, labels: Tensor, sequence_mask: Tensor) Tensor[source]
Forward pass of the UNet architecture.
- Parameters:
x (torch.Tensor) – Data to pass through the UNet architecture.
time (torch.Tensor) – Timestep embeddings.
labels (torch.Tensor, optional) – Context data (protein sequences) to guide the prediction, by default None
- Returns:
Output of the UNet architecture.
- Return type: