BINN
This is the API reference for the BINN-package. For usage examples, see Examples. Note that the API is still stabilizing and will undergo changes.
BINN
Bases: Module
A biologically informed neural network (BINN) in pure PyTorch.
If heads_ensemble=False
, we build a standard sequential network
with layer-to-layer connections.
If heads_ensemble=True
, we build an 'ensemble of heads' network:
each hidden layer also produces a separate head (dimension = n_outputs)
which is passed through a sigmoid, then summed at the end.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data_matrix
|
DataFrame
|
A DataFrame of input features (samples x features). If not needed, can be None. |
None
|
use_reactome
|
bool
|
If True, loads |
required |
mapping
|
DataFrame
|
A DataFrame describing how each input feature maps into the pathway graph.
If None, the user must rely on |
None
|
pathways
|
DataFrame
|
A DataFrame describing the edges among pathway nodes. |
None
|
entity_col
|
str
|
Datamatrix: The column for the entity, in the datamatrix file. |
'Protein'
|
input_col
|
str
|
Mapping: The column for the input in the mapping file. Should correspond to entity in the datamatrix file. |
'input'
|
translation_col
|
str
|
Mapping: The column for the translation in the mapping file. |
'translation'
|
target_col
|
str
|
Pathways: The column for the target in the pathways file. |
'target'
|
source_col
|
str
|
Pathways: The column for the source in the pathways file. |
'source'
|
activation
|
str
|
The activation function to use in each layer. Defaults to "tanh". |
'tanh'
|
n_layers
|
int
|
Number of layers in the network (depth). Defaults to 4. |
4
|
n_outputs
|
int
|
Dimension of the final output (e.g., 2 for binary classification). Defaults to 2. |
2
|
dropout
|
float
|
Dropout probability. Defaults to 0. |
0
|
heads_ensemble
|
bool
|
If True, build an ensemble-of-heads network. Otherwise, a standard MLP. |
False
|
device
|
str
|
The PyTorch device to place this model on. Defaults to "cpu". |
'cpu'
|
Attributes:
Name | Type | Description |
---|---|---|
inputs |
List[str]
|
The list of input feature names derived from the first connectivity matrix. |
layers |
Module
|
The built network (either standard sequential or ensemble-of-heads). |
layer_names |
List[List[str]]
|
The node (feature) names for each layer, for interpretability. |
connectivity_matrices |
List[DataFrame]
|
The adjacency (pruning) masks for each layer, derived from the pathway network. |
Source code in binn/model/binn.py
10 11 12 13 14 15 16 17 18 19 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 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 |
|
forward(x)
Standard forward pass; if heads_ensemble=True, sum-of-heads is used.
Source code in binn/model/binn.py
158 159 160 |
|