immuneML.ml_methods.pytorch_implementations package

Submodules

immuneML.ml_methods.pytorch_implementations.PyTorchLogisticRegression module

class immuneML.ml_methods.pytorch_implementations.PyTorchLogisticRegression.PyTorchLogisticRegression(*args: Any, **kwargs: Any)[source]

Bases: Module

forward(x)[source]

immuneML.ml_methods.pytorch_implementations.PyTorchReceptorCNN module

class immuneML.ml_methods.pytorch_implementations.PyTorchReceptorCNN.PyTorchReceptorCNN(*args: Any, **kwargs: Any)[source]

Bases: Module

This class implements the ReceptorCNN using PyTorch. This is one specific implementation of the architecture proposed in ReceptorCNN.

forward(x)[source]

Implements the forward pass through the network by applying kernels to the one-hot encoded receptors, followed by ReLU activation and max pooling. The obtained output is then concatenated to get the receptor representation. A fully-connected layer is then applied to the representation to predict the class assignment.

Parameters:

x – input data consisting of one-hot encoded immune receptors with optional positional information

Returns:

predictions of class assignment

get_max_information_gain()[source]

Information gain corresponds to Kullback-Leibler divergence between the observed probability p of an option (e.g. amino acid) ond null (or background) probability q of the option:

KL(p||q)=npnlog2pnqn=npnlog2pnnpnlog2qn=npnlog2pnlog2qnlog2qn<0(1)npnlog2pn<0(2)(1)(2)max(KL(p||q))=log2qn
Returns:

max information gain given background probabilities

rescale_weights_for_IGM()[source]

Rescales the weights in the kernels to represent information gain matrices.

immuneML.ml_methods.pytorch_implementations.SimpleLSTMGenerator module

class immuneML.ml_methods.pytorch_implementations.SimpleLSTMGenerator.SimpleLSTMGenerator(*args: Any, **kwargs: Any)[source]

Bases: Module

forward(features, hidden_and_cell_state)[source]
init_zero_state(batch_size=None)[source]

immuneML.ml_methods.pytorch_implementations.SimpleVAEGenerator module

class immuneML.ml_methods.pytorch_implementations.SimpleVAEGenerator.Decoder(*args: Any, **kwargs: Any)[source]

Bases: Module

forward(z)[source]
class immuneML.ml_methods.pytorch_implementations.SimpleVAEGenerator.Encoder(*args: Any, **kwargs: Any)[source]

Bases: Module

forward(cdr3_input, v_gene_input, j_gene_input)[source]
class immuneML.ml_methods.pytorch_implementations.SimpleVAEGenerator.SimpleVAEGenerator(*args: Any, **kwargs: Any)[source]

Bases: Module

decode(z)[source]
encode(cdr3_input, v_gene_input, j_gene_input)[source]
encoding_func(cdr3_input, v_gene_input, j_gene_input)[source]
forward(cdr3_input, v_gene_input, j_gene_input)[source]
immuneML.ml_methods.pytorch_implementations.SimpleVAEGenerator.vae_cdr3_loss(cdr3_output, cdr3_input, max_cdr3_len, z_mean, z_log_var, beta)[source]

Module contents