graph_interdependence_layer
Bases: layer
A layer that models interdependence in graph-structured data.
This layer integrates multiple graph_interdependence_head
instances to model relationships
within a graph, supporting advanced features like multi-hop dependencies, PageRank-like structures,
and flexible parameter reconciliation.
Attributes:
Name | Type | Description |
---|---|---|
m |
int
|
The input dimensionality of the layer. |
n |
int
|
The output dimensionality of the layer. |
width |
int
|
The number of |
name |
str
|
The name of the layer. |
channel_num |
int
|
The number of channels in each |
graph |
(graph, optional)
|
The graph structure to be used. If not provided, |
graph_file_path |
(str, optional)
|
Path to the file from which the graph can be loaded. |
nodes |
(list, optional)
|
A list of node identifiers in the graph. |
links |
(list, optional)
|
A list of edges in the graph. |
directed |
bool
|
Whether the graph is directed. |
with_multihop |
bool
|
Whether to enable multi-hop dependencies. |
h |
int
|
Number of hops for multi-hop dependencies. |
accumulative |
bool
|
Whether to accumulate dependencies across hops. |
with_pagerank |
bool
|
Whether to include PageRank-like dependencies in the layer. |
c |
float
|
Damping factor for PageRank dependencies. |
require_data |
bool
|
Whether data is required for the graph interdependence function. |
require_parameters |
bool
|
Whether parameters are required for the graph interdependence function. |
normalization |
bool
|
Whether to normalize the adjacency matrix. |
normalization_mode |
str
|
The normalization mode for the adjacency matrix ( |
self_dependence |
bool
|
Whether to include self-dependencies in the graph structure. |
with_dual_lphm |
bool
|
Whether to use dual LPHM reconciliation. |
with_lorr |
bool
|
Whether to use LORR reconciliation. |
r |
int
|
The rank for parameter reconciliation. |
with_residual |
bool
|
Whether to include residual connections in the layer. |
enable_bias |
bool
|
Whether to enable bias terms in parameter reconciliation. |
with_batch_norm |
bool
|
Whether to apply batch normalization to the layer's output. |
with_relu |
bool
|
Whether to apply ReLU activation to the layer's output. |
with_softmax |
bool
|
Whether to apply softmax activation to the layer's output. |
with_dropout |
bool
|
Whether to apply dropout to the layer's output. |
p |
float
|
The dropout probability. |
parameters_init_method |
str
|
The initialization method for parameters. |
device |
str
|
The device on which to run the layer ( |
Methods:
Name | Description |
---|---|
__init__ |
Initializes the graph interdependence layer. |
Source code in tinybig/layer/graph_based_layers.py
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 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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|
__init__(m, n, width=1, name='graph_interdependence_layer', channel_num=1, graph=None, graph_file_path=None, nodes=None, links=None, directed=False, with_multihop=False, h=1, accumulative=False, with_pagerank=False, c=0.15, require_data=False, require_parameters=False, normalization=True, normalization_mode='column', self_dependence=True, with_dual_lphm=False, with_lorr=False, r=3, with_residual=False, enable_bias=False, with_batch_norm=False, with_relu=True, with_softmax=True, with_dropout=True, p=0.5, parameters_init_method='xavier_normal', device='cpu', *args, **kwargs)
Initialize the graph interdependence layer.
This constructor creates a layer consisting of multiple graph interdependence heads to process and learn from graph-structured data.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
m
|
int
|
The input dimensionality of the layer. |
required |
n
|
int
|
The output dimensionality of the layer. |
required |
width
|
int
|
The number of |
1
|
name
|
str
|
The name of the layer. Default is |
'graph_interdependence_layer'
|
channel_num
|
int
|
The number of channels in each head. Default is 1. |
1
|
graph
|
graph
|
A pre-loaded graph structure. If provided, this takes precedence over |
None
|
graph_file_path
|
str
|
Path to the file containing the graph structure. |
None
|
nodes
|
list
|
A list of node identifiers. |
None
|
links
|
list
|
A list of edges representing connections between nodes. |
None
|
directed
|
bool
|
Indicates whether the graph is directed. Default is |
False
|
with_multihop
|
bool
|
If |
False
|
h
|
int
|
The number of hops to consider for multi-hop dependencies. Default is 1. |
1
|
accumulative
|
bool
|
If |
False
|
with_pagerank
|
bool
|
If |
False
|
c
|
float
|
Damping factor for PageRank dependencies. Default is 0.15. |
0.15
|
require_data
|
bool
|
If |
False
|
require_parameters
|
bool
|
If |
False
|
normalization
|
bool
|
If |
True
|
normalization_mode
|
str
|
Specifies the normalization mode ( |
'column'
|
self_dependence
|
bool
|
If |
True
|
with_dual_lphm
|
bool
|
If |
False
|
with_lorr
|
bool
|
If |
False
|
r
|
int
|
The rank used for parameter reconciliation. Default is 3. |
3
|
with_residual
|
bool
|
If |
False
|
enable_bias
|
bool
|
If |
False
|
with_batch_norm
|
bool
|
If |
False
|
with_relu
|
bool
|
If |
True
|
with_softmax
|
bool
|
If |
True
|
with_dropout
|
bool
|
If |
True
|
p
|
float
|
The dropout probability. Default is 0.5. |
0.5
|
parameters_init_method
|
str
|
Specifies the initialization method for parameters. Default is |
'xavier_normal'
|
device
|
str
|
The device on which to run the layer ( |
'cpu'
|
Raises:
Type | Description |
---|---|
ValueError
|
If a graph structure is not provided via |
Source code in tinybig/layer/graph_based_layers.py
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 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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
|