mubind.models.Mubind

class mubind.models.Mubind(datatype, **kwargs)[source]

Implements the MUBIND model.

Args:

datatype (String): Type of the experimental data. “selex” and “pbm” are supported.

Keyword Args:

n_rounds (int): Necessary for SELEX data: Number of rounds to be predicted. init_random (bool): Use a random initialization for all parameters. Default: True padding_const (double): Value for padding DNA-seqs. Default: 0.25 use_dinuc (bool): Use dinucleotide contributions (not fully implemented for all kind of models). Default: False enr_series (bool): Whether the data should be handled as enrichment series. Default: True n_batches (int): Number of batches that will occur in the data. Default: 1 ignore_kernel (list[bool]): Whether a kernel should be ignored. Default: None. kernels (List[int]): Size of the binding modes (0 indicates non-specific binding). Default: [0, 15] n_kernels (int). Number of filters to be used (including non-specific binding, as a constant).

Default: 2 (ns-binding, and one filter)

init_random (bool): Use a random initialization for all parameters. Default: True n_proteins (int): Number of proteins in the dataset. Either n_proteins or n_batches may be used. Default: 1

bm_generator (torch.nn.Module): PyTorch module which has a weight matrix as output. add_intercept (bool): Whether an intercept is used in addition to the predicted binding modes. Default: True

__init__(datatype, **kwargs)[source]

Initialize internal Module state, shared by both nn.Module and ScriptModule.

Methods

__init__(datatype, **kwargs)

Initialize internal Module state, shared by both nn.Module and ScriptModule.

add_module(name, module)

Add a child module to the current module.

apply(fn)

Apply fn recursively to every submodule (as returned by .children()) as well as self.

bfloat16()

Casts all floating point parameters and buffers to bfloat16 datatype.

buffers([recurse])

Return an iterator over module buffers.

children()

Return an iterator over immediate children modules.

compile(*args, **kwargs)

Compile this Module's forward using torch.compile().

corr_etas_libsizes(train)

cpu()

Move all model parameters and buffers to the CPU.

cuda([device])

Move all model parameters and buffers to the GPU.

dirichlet_regularization()

double()

Casts all floating point parameters and buffers to double datatype.

eval()

Set the module in evaluation mode.

exp_barrier([exp_max])

extra_repr()

Set the extra representation of the module.

float()

Casts all floating point parameters and buffers to float datatype.

forward(mono, **kwargs)

Define the computation performed at every call.

get_buffer(target)

Return the buffer given by target if it exists, otherwise throw an error.

get_extra_state()

Return any extra state to include in the module's state_dict.

get_ignore_kernel()

get_kernel_weights(index, **kwargs)

get_kernel_width(index)

get_log_activities()

get_log_etas()

get_parameter(target)

Return the parameter given by target if it exists, otherwise throw an error.

get_submodule(target)

Return the submodule given by target if it exists, otherwise throw an error.

half()

Casts all floating point parameters and buffers to half datatype.

ipu([device])

Move all model parameters and buffers to the IPU.

load_state_dict(state_dict[, strict, assign])

Copy parameters and buffers from state_dict into this module and its descendants.

loss_exp_barrier(exp_max)

We add an exponential negative term, to force weights to be more positive than negative

loss_kernel_rel([log])

Return a loss associated to the similarity of weights that are assumed to be similar

loss_kernel_symmetrical_weights()

This loss calculates the squared sum of columns per position, and it is useful to detect strong positive/negative biases per position or in the whole object.

loss_log_dynamic()

loss_prob_act()

make_model(train, n_kernels, criterion[, ...])

modify_kernel([index, shift, expand_left, ...])

modules()

Return an iterator over all modules in the network.

named_buffers([prefix, recurse, ...])

Return an iterator over module buffers, yielding both the name of the buffer as well as the buffer itself.

named_children()

Return an iterator over immediate children modules, yielding both the name of the module as well as the module itself.

named_modules([memo, prefix, remove_duplicate])

Return an iterator over all modules in the network, yielding both the name of the module as well as the module itself.

named_parameters([prefix, recurse, ...])

Return an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself.

optimize_iterative(train[, max_w, n_epochs, ...])

optimize_modified_kernel(train[, shift, ...])

optimize_simple(dataloader, optimiser[, ...])

optimize_width_and_length(train, ...[, ...])

A variation of the main optimization routine that attempts expanding the filter of the model at position i, and refines the weights and loss in order to find a better convergence.

parameters([recurse])

Return an iterator over module parameters.

print_weights()

register_backward_hook(hook)

Register a backward hook on the module.

register_buffer(name, tensor[, persistent])

Add a buffer to the module.

register_forward_hook(hook, *[, prepend, ...])

Register a forward hook on the module.

register_forward_pre_hook(hook, *[, ...])

Register a forward pre-hook on the module.

register_full_backward_hook(hook[, prepend])

Register a backward hook on the module.

register_full_backward_pre_hook(hook[, prepend])

Register a backward pre-hook on the module.

register_load_state_dict_post_hook(hook)

Register a post hook to be run after module's load_state_dict is called.

register_module(name, module)

Alias for add_module().

register_parameter(name, param)

Add a parameter to the module.

register_state_dict_pre_hook(hook)

Register a pre-hook for the state_dict() method.

requires_grad_([requires_grad])

Change if autograd should record operations on parameters in this module.

set_extra_state(state)

Set extra state contained in the loaded state_dict.

set_ignore_kernel(ignore_kernel)

set_kernel_weights(weight, index)

set_seed(seed, index[, max_value, min_value])

share_memory()

See torch.Tensor.share_memory_().

state_dict(*args[, destination, prefix, ...])

Return a dictionary containing references to the whole state of the module.

to(*args, **kwargs)

Move and/or cast the parameters and buffers.

to_empty(*, device[, recurse])

Move the parameters and buffers to the specified device without copying storage.

train([mode])

Set the module in training mode.

type(dst_type)

Casts all parameters and buffers to dst_type.

update_grad(index, value)

update_grad_activities(index, value)

update_grad_etas(value)

weight_distances_min_k([min_k, exp_delta])

xpu([device])

Move all model parameters and buffers to the XPU.

zero_grad([set_to_none])

Reset gradients of all model parameters.

Attributes

T_destination

call_super_init

dump_patches

training