peptdeep.model.building_block¶
Classes:
|
Concatenates the AA (128 ASCII codes) embedding with the modifcation vector |
|
Decode with GRU |
|
Decode with LSTM |
|
Decode w linear NN |
|
Encode AAs (26 AA letters) and modifications by CNN and LSTM layers |
|
Encode AAs (26 AA letters) and modifications by CNN and LSTM layers, then by 'SeqAttentionSum'. |
Encode AAs (26 AA letters), modifications and charge by transformers, and then by 'SeqAttentionSum' |
|
|
Two LSTM layers on AA (26 AA letters) and modifications. |
|
Encode AAs (128 ASCII codes) and modifications by CNN and LSTM layers, and then by 'SeqAttentionSum'. |
|
Encode AAs (128 ASCII codes), modifications and charge by transformers. |
Encode AAs (128 ASCII codes), modifications and charge by transformers, and then by 'SeqAttentionSum' |
|
|
AAs (128 ASCII codes) and modifications embedded by Bert, then encoded by 'SeqAttentionSum'. |
|
Encode AAs (128 ASCII codes) and modifications by transformers. |
HuggingFace transformer with a positional encoder in front. |
|
|
Transformer NN based on HuggingFace's BertEncoder class |
|
Transformer NN based on pytorch's built-in TransformerLayer class |
|
Applies a LSTM network to a AA (26 AA letters) sequence and modifications, and concatenates with charge state information |
|
Applies an LSTM network to a AA (26 AA letters) sequence & modifications |
|
Applies a LSTM network to a AA (26 AA letters) sequence and modifications, and concatenates with 'meta' information (charge, nce, instrument_indices) |
|
Encodes AA (26 AA letters) and modification vector |
Embed AA (128 ASCII codes), modification, and charge state |
|
|
Encodes AA (ASCII codes) and modification vector |
|
Encodes Charge state, Normalized Collision Energy (NCE) and Instrument for a given spectrum into a 'meta' single layer network |
|
Encodes the modification vector in a single layer feed forward network |
|
Encodes the modification vector in a single layer feed forward network, but not transforming the first k features |
|
transform sequence with the standard embedding function |
|
transform sequence input into a positional representation |
|
apply linear transformation and tensor rescaling with softmax |
|
Extract sequence features using torch.nn.Conv1D with different kernel sizes (1(residue connection),3,5,7), and then concatenate the outputs of these Conv1Ds. |
|
Extract sequence features using torch.nn.Conv1D with different kernel sizes (1(residue connection),3,5,7), and then concatenate the outputs of these Conv1Ds. |
|
returns GRU applied on sequence input |
|
returns LSTM applied on sequence input |
|
Takes a hidden layer which processes the hidden tensor as well as the 'meta' information of NCE, Instrument, Charge |
|
takes a hidden linear which processed the 'meta' information of NCE, Instrument, Charge |
|
Using PyTorch built-in Transformer layers |
Functions:
|
|
|
|
|
|
|
|
|
|
|
See invert_attention_mask() in https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L737. |
|
|
|
- peptdeep.model.building_block.AATransformerEncoding[source]¶
alias of
Input_26AA_Mod_PositionalEncoding
- class peptdeep.model.building_block.AA_Mod_Embedding(out_features, mod_feature_size=8)[source][source]¶
Bases:
ModuleConcatenates the AA (128 ASCII codes) embedding with the modifcation vector
Methods:
__init__(out_features[, mod_feature_size])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x)Define the computation performed at every call.
- __init__(out_features, mod_feature_size=8)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Decoder_GRU(in_features, out_features)[source][source]¶
Bases:
ModuleDecode with GRU
Methods:
__init__(in_features, out_features)Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x, output_len)Define the computation performed at every call.
- __init__(in_features, out_features)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x: tensor, output_len)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Decoder_LSTM(in_features, out_features)[source][source]¶
Bases:
ModuleDecode with LSTM
Methods:
__init__(in_features, out_features)Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x, output_len)Define the computation performed at every call.
- __init__(in_features, out_features)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x: tensor, output_len)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Decoder_Linear(in_features, out_features)[source][source]¶
Bases:
ModuleDecode w linear NN
Methods:
__init__(in_features, out_features)Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x)Define the computation performed at every call.
- __init__(in_features, out_features)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Encoder_26AA_Mod_CNN_LSTM(out_features, n_lstm_layers=1)[source][source]¶
Bases:
ModuleEncode AAs (26 AA letters) and modifications by CNN and LSTM layers
Methods:
__init__(out_features[, n_lstm_layers])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x)Define the computation performed at every call.
- __init__(out_features, n_lstm_layers=1)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Encoder_26AA_Mod_CNN_LSTM_AttnSum(out_features, n_lstm_layers=2)[source][source]¶
Bases:
ModuleEncode AAs (26 AA letters) and modifications by CNN and LSTM layers, then by ‘SeqAttentionSum’.
Methods:
__init__(out_features[, n_lstm_layers])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x)Define the computation performed at every call.
- __init__(out_features, n_lstm_layers=2)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Encoder_26AA_Mod_Charge_CNN_LSTM_AttnSum(out_features)[source][source]¶
Bases:
ModuleEncode AAs (26 AA letters), modifications and charge by transformers, and then by ‘SeqAttentionSum’
Methods:
__init__(out_features)Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x, charges)Define the computation performed at every call.
- __init__(out_features)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x, charges)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Encoder_26AA_Mod_LSTM(out_features, n_lstm_layers=1)[source][source]¶
Bases:
ModuleTwo LSTM layers on AA (26 AA letters) and modifications.
Methods:
__init__(out_features[, n_lstm_layers])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x)Define the computation performed at every call.
- __init__(out_features, n_lstm_layers=1)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Encoder_AA_Mod_CNN_LSTM_AttnSum(out_features, n_lstm_layers=2)[source][source]¶
Bases:
ModuleEncode AAs (128 ASCII codes) and modifications by CNN and LSTM layers, and then by ‘SeqAttentionSum’.
Methods:
__init__(out_features[, n_lstm_layers])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x)Define the computation performed at every call.
- __init__(out_features, n_lstm_layers=2)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Encoder_AA_Mod_Charge_Transformer(out_features, dropout=0.1, nlayers=4, output_attentions=False)[source][source]¶
Bases:
ModuleEncode AAs (128 ASCII codes), modifications and charge by transformers.
Methods:
__init__(out_features[, dropout, nlayers, ...])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x, charges[, ...])Define the computation performed at every call.
- __init__(out_features, dropout=0.1, nlayers=4, output_attentions=False)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x, charges, attention_mask=None)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Encoder_AA_Mod_Charge_Transformer_AttnSum(out_features, dropout=0.1, nlayers=4, output_attentions=False)[source][source]¶
Bases:
ModuleEncode AAs (128 ASCII codes), modifications and charge by transformers, and then by ‘SeqAttentionSum’
Methods:
__init__(out_features[, dropout, nlayers, ...])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x, charges)Define the computation performed at every call.
- __init__(out_features, dropout=0.1, nlayers=4, output_attentions=False)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x, charges)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Encoder_AA_Mod_Transformer(out_features, dropout=0.1, nlayers=4, output_attentions=False)[source][source]¶
Bases:
ModuleAAs (128 ASCII codes) and modifications embedded by Bert, then encoded by ‘SeqAttentionSum’.
Methods:
__init__(out_features[, dropout, nlayers, ...])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x[, attention_mask])Define the computation performed at every call.
- __init__(out_features, dropout=0.1, nlayers=4, output_attentions=False)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x, attention_mask=None)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Encoder_AA_Mod_Transformer_AttnSum(out_features, dropout=0.1, nlayers=4, output_attentions=False)[source][source]¶
Bases:
ModuleEncode AAs (128 ASCII codes) and modifications by transformers.
Methods:
__init__(out_features[, dropout, nlayers, ...])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x)Define the computation performed at every call.
- __init__(out_features, dropout=0.1, nlayers=4, output_attentions=False)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.HFace_Transformer_with_PositionalEncoder(hidden_dim: int, hidden_expand=4, nheads=8, nlayers=4, dropout=0.1, output_attentions=False, max_len=200)[source][source]¶
Bases:
ModuleHuggingFace transformer with a positional encoder in front.
- Parameters:
hidden_dim (int) – Input and output feature dimension.
hidden_expand (int, optional) – FFN hidden size = hidden*hidden_expand. Defaults to 4.
nhead (int, optional) – Multi-head attention number. Defaults to 8.
nlayers (int, optional) – Number of transformer layers. Defaults to 4.
dropout (float, optional) – Dropout rate. Defaults to 0.1.
output_attentions (bool, optional) – If output attention values. Defaults to False.
max_len (int, optional) – Max input sequence length. Defaults to 200.
Methods:
__init__(hidden_dim[, hidden_expand, ...])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x[, attention_mask])
- peptdeep.model.building_block.HiddenBert[source]¶
alias of
Hidden_HFace_Transformer
- class peptdeep.model.building_block.Hidden_HFace_Transformer(hidden_dim, hidden_expand=4, nheads=8, nlayers=4, dropout=0.1, output_attentions=False)[source][source]¶
Bases:
ModuleTransformer NN based on HuggingFace’s BertEncoder class
Methods:
__init__(hidden_dim[, hidden_expand, ...])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x[, attention_mask])- __init__(hidden_dim, hidden_expand=4, nheads=8, nlayers=4, dropout=0.1, output_attentions=False)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x: Tensor, attention_mask: Tensor = None) tuple[source][source]¶
- Parameters:
x (torch.Tensor) – shape = (batch, seq_len, dim)
attention_mask (torch.Tensor) – shape = (batch, seq_len), [0,1] tensor , 1=enable
- Returns:
out[0] is the hidden layer output, and out[1] is the output attention if self.output_attentions==True
- Return type:
(Tensor, [Tensor])
- class peptdeep.model.building_block.Hidden_Transformer(hidden, hidden_expand=4, nheads=8, nlayers=4, dropout=0.1)[source][source]¶
Bases:
ModuleTransformer NN based on pytorch’s built-in TransformerLayer class
Methods:
__init__(hidden[, hidden_expand, nheads, ...])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x)Define the computation performed at every call.
- __init__(hidden, hidden_expand=4, nheads=8, nlayers=4, dropout=0.1)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- peptdeep.model.building_block.InputAAEmbedding[source]¶
alias of
AA_Mod_Embedding
- peptdeep.model.building_block.InputAALSTM[source]¶
alias of
Input_26AA_Mod_LSTM
- peptdeep.model.building_block.InputAALSTM_cat_Charge[source]¶
alias of
Input_26AA_Mod_Charge_LSTM
- peptdeep.model.building_block.InputAALSTM_cat_Meta[source]¶
alias of
Input_26AA_Mod_Meta_LSTM
- peptdeep.model.building_block.InputMetaNet[source]¶
alias of
Meta_Embedding
- peptdeep.model.building_block.InputModNet[source]¶
alias of
Mod_Embedding
- peptdeep.model.building_block.InputModNetFixFirstK[source]¶
alias of
Mod_Embedding_FixFirstK
- class peptdeep.model.building_block.Input_26AA_Mod_Charge_LSTM(out_features)[source][source]¶
Bases:
ModuleApplies a LSTM network to a AA (26 AA letters) sequence and modifications, and concatenates with charge state information
Methods:
__init__(out_features)Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x, charges)Define the computation performed at every call.
- __init__(out_features)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x, charges)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Input_26AA_Mod_LSTM(out_features, n_lstm_layers=1)[source][source]¶
Bases:
ModuleApplies an LSTM network to a AA (26 AA letters) sequence & modifications
Methods:
__init__(out_features[, n_lstm_layers])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x)Define the computation performed at every call.
- __init__(out_features, n_lstm_layers=1)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Input_26AA_Mod_Meta_LSTM(out_features)[source][source]¶
Bases:
ModuleApplies a LSTM network to a AA (26 AA letters) sequence and modifications, and concatenates with ‘meta’ information (charge, nce, instrument_indices)
Methods:
__init__(out_features)Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x, charges, NCEs, ...)Define the computation performed at every call.
- __init__(out_features)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x, charges, NCEs, instrument_indices)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Input_26AA_Mod_PositionalEncoding(out_features, max_len=200)[source][source]¶
Bases:
ModuleEncodes AA (26 AA letters) and modification vector
Methods:
__init__(out_features[, max_len])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x)Define the computation performed at every call.
- __init__(out_features, max_len=200)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- peptdeep.model.building_block.Input_AA_CNN_Encoder[source]¶
alias of
Encoder_26AA_Mod_CNN_LSTM
- peptdeep.model.building_block.Input_AA_CNN_LSTM_Encoder[source]¶
alias of
Encoder_26AA_Mod_CNN_LSTM_AttnSum
- peptdeep.model.building_block.Input_AA_LSTM_Encoder[source]¶
alias of
Encoder_26AA_Mod_LSTM
- class peptdeep.model.building_block.Input_AA_Mod_Charge_PositionalEncoding(out_features, max_len=200)[source][source]¶
Bases:
ModuleEmbed AA (128 ASCII codes), modification, and charge state
Methods:
__init__(out_features[, max_len])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x, charges)Define the computation performed at every call.
- __init__(out_features, max_len=200)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x, charges)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Input_AA_Mod_PositionalEncoding(out_features, max_len=200)[source][source]¶
Bases:
ModuleEncodes AA (ASCII codes) and modification vector
Methods:
__init__(out_features[, max_len])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(aa_indices, mod_x)Define the computation performed at every call.
- __init__(out_features, max_len=200)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(aa_indices, mod_x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- peptdeep.model.building_block.LinearDecoder[source]¶
alias of
Decoder_Linear
- class peptdeep.model.building_block.Meta_Embedding(out_features)[source][source]¶
Bases:
ModuleEncodes Charge state, Normalized Collision Energy (NCE) and Instrument for a given spectrum into a ‘meta’ single layer network
Methods:
__init__(out_features)Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(charges, NCEs, instrument_indices)Define the computation performed at every call.
- __init__(out_features)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(charges, NCEs, instrument_indices)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Mod_Embedding(out_features)[source][source]¶
Bases:
ModuleEncodes the modification vector in a single layer feed forward network
Methods:
__init__(out_features)Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(mod_x)Define the computation performed at every call.
- __init__(out_features)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(mod_x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Mod_Embedding_FixFirstK(out_features)[source][source]¶
Bases:
ModuleEncodes the modification vector in a single layer feed forward network, but not transforming the first k features
Methods:
__init__(out_features)Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(mod_x)Define the computation performed at every call.
- __init__(out_features)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(mod_x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- peptdeep.model.building_block.OutputLSTM_cat_Meta[source]¶
alias of
Seq_Meta_LSTM
- peptdeep.model.building_block.OutputLinear_cat_Meta[source]¶
alias of
Seq_Meta_Linear
- class peptdeep.model.building_block.PositionalEmbedding(out_features=128, max_len=200)[source][source]¶
Bases:
Moduletransform sequence with the standard embedding function
Methods:
__init__([out_features, max_len])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x)Define the computation performed at every call.
- __init__(out_features=128, max_len=200)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x: Tensor)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.PositionalEncoding(out_features=128, max_len=200)[source][source]¶
Bases:
Moduletransform sequence input into a positional representation
Methods:
__init__([out_features, max_len])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x)Define the computation performed at every call.
- __init__(out_features=128, max_len=200)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.SeqAttentionSum(in_features)[source][source]¶
Bases:
Moduleapply linear transformation and tensor rescaling with softmax
Methods:
__init__(in_features)Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x)Define the computation performed at every call.
- __init__(in_features)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.SeqCNN(embedding_hidden)[source][source]¶
Bases:
ModuleExtract sequence features using torch.nn.Conv1D with different kernel sizes (1(residue connection),3,5,7), and then concatenate the outputs of these Conv1Ds. The Output dim is 4*embedding_hidden.
Methods:
__init__(embedding_hidden)Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x)Define the computation performed at every call.
- __init__(embedding_hidden)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.SeqCNN_MultiKernel(out_features: int)[source][source]¶
Bases:
ModuleExtract sequence features using torch.nn.Conv1D with different kernel sizes (1(residue connection),3,5,7), and then concatenate the outputs of these Conv1Ds.
Methods:
- __init__(out_features: int)[source][source]¶
- Parameters:
out_features (int) – Must be divided by 4.
- Raises:
ValueError – “out_features must be divided by 4”
- forward(x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.SeqGRU(in_features, out_features, rnn_layer=2, bidirectional=True)[source][source]¶
Bases:
Modulereturns GRU applied on sequence input
Methods:
__init__(in_features, out_features[, ...])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x)Define the computation performed at every call.
- __init__(in_features, out_features, rnn_layer=2, bidirectional=True)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x: Tensor)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- peptdeep.model.building_block.SeqGRUDecoder[source]¶
alias of
Decoder_GRU
- class peptdeep.model.building_block.SeqLSTM(in_features, out_features, rnn_layer=2, bidirectional=True)[source][source]¶
Bases:
Modulereturns LSTM applied on sequence input
Methods:
__init__(in_features, out_features[, ...])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x)Define the computation performed at every call.
- __init__(in_features, out_features, rnn_layer=2, bidirectional=True)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x: Tensor)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- peptdeep.model.building_block.SeqLSTMDecoder[source]¶
alias of
Decoder_LSTM
- class peptdeep.model.building_block.Seq_Meta_LSTM(in_features, out_features)[source][source]¶
Bases:
ModuleTakes a hidden layer which processes the hidden tensor as well as the ‘meta’ information of NCE, Instrument, Charge
Methods:
__init__(in_features, out_features)Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x, charges, NCEs, instrument_indices)Define the computation performed at every call.
- __init__(in_features, out_features)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x, charges, NCEs, instrument_indices)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Seq_Meta_Linear(in_features, out_features)[source][source]¶
Bases:
Moduletakes a hidden linear which processed the ‘meta’ information of NCE, Instrument, Charge
Methods:
__init__(in_features, out_features)Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x, charges, NCEs, instrument_indices)Define the computation performed at every call.
- __init__(in_features, out_features)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x, charges, NCEs, instrument_indices)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- class peptdeep.model.building_block.Seq_Transformer(in_features, hidden_features, nheads=8, nlayers=2, dropout=0.1)[source][source]¶
Bases:
ModuleUsing PyTorch built-in Transformer layers
Methods:
__init__(in_features, hidden_features[, ...])Initialize internal Module state, shared by both nn.Module and ScriptModule.
forward(x)Define the computation performed at every call.
- __init__(in_features, hidden_features, nheads=8, nlayers=2, dropout=0.1)[source][source]¶
Initialize internal Module state, shared by both nn.Module and ScriptModule.
- forward(x)[source][source]¶
Define the computation performed at every call.
Should be overridden by all subclasses.
Note
Although the recipe for forward pass needs to be defined within this function, one should call the
Moduleinstance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.
- peptdeep.model.building_block.invert_attention_mask(encoder_attention_mask: Tensor, dtype=torch.float32) FloatTensor[source][source]¶
See invert_attention_mask() in https://github.com/huggingface/transformers/blob/main/src/transformers/modeling_utils.py#L737. Invert an attention mask (e.g., switches 0. and 1.). :param encoder_attention_mask: An attention mask. :type encoder_attention_mask: torch.Tensor
- Returns:
The inverted attention mask.
- Return type:
torch.Tensor