Core
Abstract base classes for defining SOMs.
AbstractSom
Bases: Module
Abstract base class for SOM models.
Source code in src/somap/core.py
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 |
|
__call__(input)
Makes a single iteration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input |
InputData
|
Data array for the given SOM models. |
required |
Returns:
Type | Description |
---|---|
A tuple with the new SOM model and the auxilary data. |
Source code in src/somap/core.py
__init__(shape, topography, borderless, input_shape, params, metrics=True, debug=False, key=jax.random.PRNGKey(0))
Creates a SOM models.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
shape |
Shape of the 2D map. |
required | |
topography |
Topography of the 2D map. Either 'square' for a square grid or 'hex' for hexagonal grid. |
required | |
borderless |
Toroidal topography if True, meaning that the top (resp. left) border meets the bottom (resp. right) border. |
required | |
input_shape |
Shape of the input data. |
required | |
params |
Parameters of the SOM (depends on the SOM flavor). |
required | |
metrics |
If True, returns quantization and topographic errors as auxilary data. |
True
|
|
debug |
If True, returns debug data as auxilary data. |
False
|
|
key |
PRNGKeyArray
|
JAX random key used during map initialization. |
PRNGKey(0)
|
Source code in src/somap/core.py
bulk_set(attr_dict)
Sets multiples attributes at once.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attr_dict |
dictionary where keys are attribute names and values are attributes values to be set. |
required |
Returns:
Type | Description |
---|---|
A new instance of the updated object. |
Source code in src/somap/core.py
generate_algo(params)
set(attribute, value)
Sets an attribute to a specific value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attribute |
str
|
name of the attribute. |
required |
value |
new value of the attribute. |
required |
Returns:
Type | Description |
---|---|
A new instance of the updated object. |
Source code in src/somap/core.py
AbstractSomParams
InputData
Bases: TypedDict
Structure of the input data.
Note
Classical SOMs only have the 'bu_v' bottum-up input value. Other inputs allow to create more complex SOMs receiving top-down and lateral inputs with a mask.
Note bis
TypedDict instead of dataclass to facilitate future modifications.
Source code in src/somap/core.py
SomAlgo
make_step(model, input)
Makes a single iteration.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
AbstractSom
|
SOM model. |
required |
input |
InputData
|
Data array for the given SOM models. |
required |
Returns:
Type | Description |
---|---|
A tuple with the new SOM model and the auxilary data. |
Source code in src/somap/core.py
make_steps(model, inputs)
Makes multiple iterations at once.
Uses the jax.lax.scan()
function to optimize computations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
AbstractSom
|
SOM model. |
required |
inputs |
Batch data array for the given SOM models. |
required |
Returns:
Type | Description |
---|---|
A tuple with the new SOM model and the auxilary data. |