Knapsack beam search
KnapsackBeamSearchDecoder(model, knapsack)
Bases: BeamSearchDecoder
A class for decoding from de novo sequencing models using beam search with knapsack filtering.
Source code in instanovo/inference/knapsack_beam_search.py
from_file(model, path)
classmethod
Initialize a decoder by loading a saved knapsack.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
Decodable
|
The model to be decoded from. |
required |
path |
str
|
The path to the directory where the knapsack was saved to. |
required |
Returns:
Name | Type | Description |
---|---|---|
KnapsackBeamSearchDecoder |
KnapsackBeamSearchDecoder
|
The decoder. |
Source code in instanovo/inference/knapsack_beam_search.py
prefilter_items(log_probabilities, remaining_masses, beam_masses, mass_buffer, max_isotope)
Filter illegal next token by setting the corresponding log probabilities to -inf
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
log_probabilities |
torch.FloatTensor[batch size, beam size, number of residues]
|
The candidate log probabilities for each item on the beam and each potential next residue for batch spectrum in the batch. |
required |
remaining_masses |
torch.LongTensor[batch size, beam size]
|
|
required |
mass_buffer |
torch.LongTensor[batch size, 1, 1]
|
description |
required |
Returns:
Type | Description |
---|---|
FloatTensor
|
torch.FloatTensor: description |