networkvi.nn.GOLayers#
- class networkvi.nn.GOLayers(geneobj, genemodel_out_blocks, ensembl_ids, obo_file: str, map_ensembl_go: list | ~numpy.ndarray, standard_go_size: int = 6, input_dropout: float = 0.1, n_layers: int = 5, n_hidden: int = 128, activation_fn: ~torch.nn.modules.module.Module = <class 'torch.nn.modules.activation.ReLU'>, dynamic_go_size: bool = False, register_rancon: bool = False, remove_rancon: bool = False, n_cat_list=None, inject_covariates: bool = True, first_layer_inject_covariates: bool = True, last_layer_inject_covariates: bool = True, *args, **kwargs)#
A helper class to build GOLayers for a neural network.
- Parameters:
geneobj – geneobj generated using GeneLayers.
genemodel_out_blocks – out blocks sparse matrix of object generated using GeneLayers.
ensembl_ids – ENSEMBL-IDs of features.
obo_file – Path .obo file of GO.
map_ensembl_go – List of .gaf files with mappings of Ensembl IDs to GO.
standard_go_size – Standard size of GO nodes in GO Layers.
input_dropout – Dropout rate to apply to each of the hidden layers
n_layers – The number of fully-connected hidden layers
n_hidden – The number of nodes per hidden layer
activation_fn – Which activation function to use
n_cat_list – A list containing, for each category of interest, the number of categories. Each category will be included using a one-hot encoding.
inject_covariates – Whether to deeply inject covariates into all layers of the endecoder. If False, covariates will only be included in the input layer.
first_layer_inject_covariates – Whether to deeply inject covariates into all layers of the decoder. If False, covariates will only be included in the input layer.
last_layer_inject_covariates – Whether to inject covariates into all layers of the decoder. If False, covariates will only be included in the input layer.
- __init__(geneobj, genemodel_out_blocks, ensembl_ids, obo_file: str, map_ensembl_go: list | ~numpy.ndarray, standard_go_size: int = 6, input_dropout: float = 0.1, n_layers: int = 5, n_hidden: int = 128, activation_fn: ~torch.nn.modules.module.Module = <class 'torch.nn.modules.activation.ReLU'>, dynamic_go_size: bool = False, register_rancon: bool = False, remove_rancon: bool = False, n_cat_list=None, inject_covariates: bool = True, first_layer_inject_covariates: bool = True, last_layer_inject_covariates: bool = True, *args, **kwargs)#
Initialize internal Module state, shared by both nn.Module and ScriptModule.
Methods
__init__(geneobj, genemodel_out_blocks, ...)Initialize internal Module state, shared by both nn.Module and ScriptModule.
add_module(name, module)Add a child module to the current module.
apply(fn)Apply
fnrecursively to every submodule (as returned by.children()) as well as self.bfloat16()Casts all floating point parameters and buffers to
bfloat16datatype.buffers([recurse])Return an iterator over module buffers.
children()Return an iterator over immediate children modules.
compile(*args, **kwargs)Compile this Module's forward using
torch.compile().cpu()Move all model parameters and buffers to the CPU.
cuda([device])Move all model parameters and buffers to the GPU.
double()Casts all floating point parameters and buffers to
doubledatatype.eval()Set the module in evaluation mode.
extra_repr()Set the extra representation of the module.
float()Casts all floating point parameters and buffers to
floatdatatype.forward(x, *cat_list[, cont_input])Define the computation performed at every call.
get_buffer(target)Return the buffer given by
targetif it exists, otherwise throw an error.get_ds_terms_and_parents(unknown, goobj, gos)get_extra_state()Return any extra state to include in the module's state_dict.
get_goobj_info()get_n_parameters()get_neurons_available(dynamic_go_cfg, ...)Returns the OGM's number of neurons available for distribution per height level.
get_ordered_gos(ensemblids, genetic_json, ...)get_overflow_info(dynamic_go_cfg, ...)get_parameter(target)Return the parameter given by
targetif it exists, otherwise throw an error.get_parents(term)get_sizes_by_level([name])Returns the OGM's layersizes ordered per depth/ogmdepth/height as dict mapping level -> list of layersizes
get_submodule(target)Return the submodule given by
targetif it exists, otherwise throw an error.get_total_size()Returns the OGM's total number of neurons.
half()Casts all floating point parameters and buffers to
halfdatatype.initialize_go_obj(mode, obo_file, max_level, ...)ipu([device])Move all model parameters and buffers to the IPU.
load_state_dict(state_dict[, strict, assign])Copy parameters and buffers from
state_dictinto this module and its descendants.modules()Return an iterator over all modules in the network.
named_buffers([prefix, recurse, ...])Return an iterator over module buffers, yielding both the name of the buffer as well as the buffer itself.
named_children()Return an iterator over immediate children modules, yielding both the name of the module as well as the module itself.
named_modules([memo, prefix, remove_duplicate])Return an iterator over all modules in the network, yielding both the name of the module as well as the module itself.
named_parameters([prefix, recurse, ...])Return an iterator over module parameters, yielding both the name of the parameter as well as the parameter itself.
parameters([recurse])Return an iterator over module parameters.
patch_bup_ontology(goobj, relations)Patch ontology built from the bottom up (i.e. with filtering for max_level height).
register_backward_hook(hook)Register a backward hook on the module.
register_buffer(name, tensor[, persistent])Add a buffer to the module.
register_forward_hook(hook, *[, prepend, ...])Register a forward hook on the module.
register_forward_pre_hook(hook, *[, ...])Register a forward pre-hook on the module.
register_full_backward_hook(hook[, prepend])Register a backward hook on the module.
register_full_backward_pre_hook(hook[, prepend])Register a backward pre-hook on the module.
register_load_state_dict_post_hook(hook)Register a post hook to be run after module's
load_state_dictis called.register_module(name, module)Alias for
add_module().register_parameter(name, param)Add a parameter to the module.
register_state_dict_pre_hook(hook)Register a pre-hook for the
load_state_dict()method.requires_grad_([requires_grad])Change if autograd should record operations on parameters in this module.
set_ensemblids(unknown, goobj, gos, ensemblids)Sets the ensemblid attribute for every GOTerm of the GO object.
set_extra_state(state)Set extra state contained in the loaded state_dict.
set_layersize(goobj, relations, ...)Sets the layersize attribute for every GOTerm of the GO object.
set_layersize_dynamic(dynamic_go_cfg, goobj, ...)set_topnode_and_unknown(goobj, ontology, ...)Sets and returns the top (root) node and UNKNOWN node of the ontology.
share_memory()See
torch.Tensor.share_memory_().state_dict(*args[, destination, prefix, ...])Return a dictionary containing references to the whole state of the module.
to(*args, **kwargs)Move and/or cast the parameters and buffers.
to_empty(*, device[, recurse])Move the parameters and buffers to the specified device without copying storage.
train([mode])Set the module in training mode.
type(dst_type)Casts all parameters and buffers to
dst_type.xpu([device])Move all model parameters and buffers to the XPU.
zero_grad([set_to_none])Reset gradients of all model parameters.
Attributes
T_destinationcall_super_initdump_patchestraining