Model
MassSpectrumTransFusion(cfg, max_transcript_len=200)
Bases: TransFusion
Diffusion reconstruction model conditioned on mass spectra.
Source code in instanovo/diffusion/model.py
forward(x, t, spectra, spectra_padding_mask, precursors, x_padding_mask=None)
Transformer with conditioning cross attention.
x
: (bs, seq_len) long tensor of character indices or (bs, seq_len, vocab_size) if cfg.diffusion_type == 'continuous't
: (bs, ) long tensor of timestep indicescond_emb
: (bs, seq_len2, cond_emb_dim) if using wavlm encoder, else (bs, T)x_padding_mask
: (bs, seq_len) if using wavlm encoder, else (bs, T)cond_padding_mask
: (bs, seq_len2)
Returns logits (bs, seq_len, vocab_size)
Source code in instanovo/diffusion/model.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 |
|
MassSpectrumTransformer
Bases: Pogfuse
A transformer model specialised for encoding mass spectra.
forward(x, t_emb, precursor_emb, cond_emb=None, x_padding_mask=None, cond_padding_mask=None, pos_bias=None)
Compute encodings with the model.
Forward with x
(bs, seq_len, dim), summing t_emb
(bs, dim) before the transformer layer,
and appending conditioning_emb
(bs, seq_len2, dim) to the key/value pairs of the attention.
Also pooled_conv_emb
(bs, dim) is summed with the timestep embeddings
Optionally specify key/value padding for input x
with x_padding_mask
(bs, seq_len), and optionally
specify key/value padding mask for conditional embedding with cond_padding_mask
(bs, seq_len2).
By default no padding is used. Good idea to use cond padding but not x padding.
pos_bias
is positional bias for wavlm-style attention gated relative position bias.
Returns x
of same shape (bs, seq_len, dim)