Model
InstaNovo(i2s, residues, dim_model=768, n_head=16, dim_feedforward=2048, n_layers=9, dropout=0.1, max_length=30, max_charge=5, bos_id=1, eos_id=2, use_depthcharge=True, enc_type='depthcharge', dec_type='depthcharge', dec_precursor_sos=False)
Bases: Module
The Instanovo model.
Source code in instanovo/transformer/model.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
batch_idx_to_aa(idx)
decode(sequence)
forward(x, p, y, x_mask=None, y_mask=None, add_bos=True)
Model forward pass.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
x |
Tensor
|
Spectra, float Tensor (batch, n_peaks, 2) |
required |
p |
Tensor
|
Precursors, float Tensor (batch, 3) |
required |
y |
Tensor
|
Peptide, long Tensor (batch, seq_len, vocab) |
required |
x_mask |
Tensor
|
Spectra padding mask, True for padded indices, bool Tensor (batch, n_peaks) |
None
|
y_mask |
Tensor
|
Peptide padding mask, bool Tensor (batch, seq_len) |
None
|
add_bos |
bool
|
Force add a |
True
|
Returns:
Name | Type | Description |
---|---|---|
logits |
Tensor
|
float Tensor (batch, n, vocab_size), |
Tensor
|
(batch, n+1, vocab_size) if add_bos==True. |
Source code in instanovo/transformer/model.py
get_empty_index()
get_eos_index()
get_residue_masses(mass_scale)
Get the scaled masses of all residues.
Source code in instanovo/transformer/model.py
idx_to_aa(idx)
Decode a single sample of indices to aa list.
Source code in instanovo/transformer/model.py
init(x, p, x_mask=None)
Initialise model encoder.
Source code in instanovo/transformer/model.py
load(path)
classmethod
Load model from checkpoint.
Source code in instanovo/transformer/model.py
score_candidates(y, p, x, x_mask)
Score a set of candidate sequences.