Catalog of different flavors of SOMs.
To add a new SOMs, define the 2 following classes:
class MySomParams(AbstractSomParams):
pass
class MySom(AbstractSom):
pass
Dsom
Bases: AbstractSom
Dynamic SOM.
Source code in src/somap/som.py
| class Dsom(AbstractSom):
"""Dynamic SOM."""
@staticmethod
def generate_algo(p: DsomParams) -> SomAlgo:
"""Converts Dynamic SOM parameters into generic SOM functions."""
return SomAlgo(
f_dist=EuclidianDist(),
f_nbh=DsomNbh(plasticity=p.plasticity),
f_lr=DsomLr(alpha=p.alpha),
f_update=SomUpdate(),
)
|
generate_algo(p)
staticmethod
Converts Dynamic SOM parameters into generic SOM functions.
Source code in src/somap/som.py
| @staticmethod
def generate_algo(p: DsomParams) -> SomAlgo:
"""Converts Dynamic SOM parameters into generic SOM functions."""
return SomAlgo(
f_dist=EuclidianDist(),
f_nbh=DsomNbh(plasticity=p.plasticity),
f_lr=DsomLr(alpha=p.alpha),
f_update=SomUpdate(),
)
|
DsomParams
Bases: AbstractSomParams
Dynamic SOM parameters.
Source code in src/somap/som.py
| class DsomParams(AbstractSomParams):
"""Dynamic SOM parameters."""
plasticity: float | Float[Array, "..."]
alpha: float | Float[Array, "..."]
|
Ksom
Bases: AbstractSom
Kohonen SOM.
Source code in src/somap/som.py
| class Ksom(AbstractSom):
"""Kohonen SOM."""
@staticmethod
def generate_algo(p: KsomParams) -> SomAlgo:
"""Converts Kohonen SOM parameters into generic SOM functions."""
return SomAlgo(
f_dist=EuclidianDist(),
f_nbh=KsomNbh(t_f=p.t_f, sigma_i=p.sigma_i, sigma_f=p.sigma_f),
f_lr=KsomLr(t_f=p.t_f, alpha_i=p.alpha_i, alpha_f=p.alpha_f),
f_update=SomUpdate(),
)
|
generate_algo(p)
staticmethod
Converts Kohonen SOM parameters into generic SOM functions.
Source code in src/somap/som.py
| @staticmethod
def generate_algo(p: KsomParams) -> SomAlgo:
"""Converts Kohonen SOM parameters into generic SOM functions."""
return SomAlgo(
f_dist=EuclidianDist(),
f_nbh=KsomNbh(t_f=p.t_f, sigma_i=p.sigma_i, sigma_f=p.sigma_f),
f_lr=KsomLr(t_f=p.t_f, alpha_i=p.alpha_i, alpha_f=p.alpha_f),
f_update=SomUpdate(),
)
|
KsomParams
Bases: AbstractSomParams
Kohonen SOM parameters.
Source code in src/somap/som.py
| class KsomParams(AbstractSomParams):
"""Kohonen SOM parameters."""
t_f: int | Integer[Array, "..."]
sigma_i: float | Float[Array, "..."]
sigma_f: float | Float[Array, "..."]
alpha_i: float | Float[Array, "..."]
alpha_f: float | Float[Array, "..."]
|
Som
Bases: AbstractSom
Generic SOM.
Distance, neighborhood, learning rate and update functions are directly specified.
This is the more flexible way of defining a SOM.
Source code in src/somap/som.py
| class Som(AbstractSom):
"""Generic SOM.
Distance, neighborhood, learning rate and update functions are directly specified.
This is the more flexible way of defining a SOM.
"""
@staticmethod
def generate_algo(p: SomParams) -> SomAlgo:
"""Identity function returning generic SOM functions."""
return SomAlgo(
f_dist=p.f_dist,
f_nbh=p.f_nbh,
f_lr=p.f_lr,
f_update=p.f_update,
)
|
generate_algo(p)
staticmethod
Identity function returning generic SOM functions.
Source code in src/somap/som.py
| @staticmethod
def generate_algo(p: SomParams) -> SomAlgo:
"""Identity function returning generic SOM functions."""
return SomAlgo(
f_dist=p.f_dist,
f_nbh=p.f_nbh,
f_lr=p.f_lr,
f_update=p.f_update,
)
|
SomParams
Bases: AbstractSomParams
, SomAlgo
Generic SOM parameters.
Same as the SomAlgo
class but with the AbstractSomParams
parent.
Source code in src/somap/som.py
| class SomParams(AbstractSomParams, SomAlgo):
"""Generic SOM parameters.
Same as the `SomAlgo` class but with the `AbstractSomParams` parent.
"""
pass
|
StaticKsom
Bases: AbstractSom
Time-independant Kohonen SOM.
Source code in src/somap/som.py
| class StaticKsom(AbstractSom):
"""Time-independant Kohonen SOM."""
@staticmethod
def generate_algo(p: StaticKsomParams) -> SomAlgo:
"""Converts Static Kohonen SOM parameters into generic SOM functions."""
return SomAlgo(
f_dist=EuclidianDist(),
f_nbh=GaussianNbh(sigma=p.sigma),
f_lr=ConstantLr(alpha=p.alpha),
f_update=SomUpdate(),
)
|
generate_algo(p)
staticmethod
Converts Static Kohonen SOM parameters into generic SOM functions.
Source code in src/somap/som.py
| @staticmethod
def generate_algo(p: StaticKsomParams) -> SomAlgo:
"""Converts Static Kohonen SOM parameters into generic SOM functions."""
return SomAlgo(
f_dist=EuclidianDist(),
f_nbh=GaussianNbh(sigma=p.sigma),
f_lr=ConstantLr(alpha=p.alpha),
f_update=SomUpdate(),
)
|
StaticKsomParams
Bases: AbstractSomParams
Time-independant Kohonen SOM parameters.
Source code in src/somap/som.py
| class StaticKsomParams(AbstractSomParams):
"""Time-independant Kohonen SOM parameters."""
sigma: float | Float[Array, "..."]
alpha: float | Float[Array, "..."]
|