deepnog.inference
¶
Author: Roman Feldbauer
Date: 2020-02-19
Description:
Predict orthologous groups of protein sequences.
-
deepnog.inference.
load_nn
(architecture, model_dict, device='cpu')[source]¶ Import NN architecture and set loaded parameters.
- Parameters
architecture (str) – Name of neural network module and class to import.
model_dict (dict) – Dictionary holding all parameters and hyper-parameters of the model.
device ([str, torch.device]) – Device to load the model into.
- Returns
model – Neural network object of type architecture with parameters loaded from model_dict and moved to device.
- Return type
torch.nn.Module
-
deepnog.inference.
predict
(model, dataset, device='cpu', batch_size=16, num_workers=4, verbose=3)[source]¶ Use model to predict zero-indexed labels of dataset.
Also handles communication with ProteinIterators used to load data to log how many sequences have been skipped due to having empty sequence ids.
- Parameters
model (nn.Module) – Trained neural network model.
dataset (ProteinDataset) – Data to predict protein families for.
device ([str, torch.device]) – Device of model.
batch_size (int) – Forward batch_size proteins through neural network at once.
num_workers (int) – Number of workers for data loading.
verbose (int) – Define verbosity.
- Returns
preds (torch.Tensor, shape (n_samples,)) – Stores the index of the output-node with the highest activation
confs (torch.Tensor, shape (n_samples,)) – Stores the confidence in the prediction
ids (list[str]) – Stores the (possible empty) protein labels extracted from data file.
indices (list[int]) – Stores the unique indices of sequences mapping to their position in the file