[BUGFIX] examples/ksom_colors.py
works again
This commit is contained in:
parent
3afced8662
commit
4eafe88dc4
@ -6,20 +6,7 @@ import prototorch as pt
|
|||||||
import pytorch_lightning as pl
|
import pytorch_lightning as pl
|
||||||
import torch
|
import torch
|
||||||
from matplotlib import pyplot as plt
|
from matplotlib import pyplot as plt
|
||||||
|
from prototorch.utils.colors import hex_to_rgb
|
||||||
|
|
||||||
def hex_to_rgb(hex_values):
|
|
||||||
for v in hex_values:
|
|
||||||
v = v.lstrip('#')
|
|
||||||
lv = len(v)
|
|
||||||
c = [int(v[i:i + lv // 3], 16) for i in range(0, lv, lv // 3)]
|
|
||||||
yield c
|
|
||||||
|
|
||||||
|
|
||||||
def rgb_to_hex(rgb_values):
|
|
||||||
for v in rgb_values:
|
|
||||||
c = "%02x%02x%02x" % tuple(v)
|
|
||||||
yield c
|
|
||||||
|
|
||||||
|
|
||||||
class Vis2DColorSOM(pl.Callback):
|
class Vis2DColorSOM(pl.Callback):
|
||||||
@ -92,7 +79,7 @@ if __name__ == "__main__":
|
|||||||
# Initialize the model
|
# Initialize the model
|
||||||
model = pt.models.KohonenSOM(
|
model = pt.models.KohonenSOM(
|
||||||
hparams,
|
hparams,
|
||||||
prototype_initializer=pt.components.Random(3),
|
prototypes_initializer=pt.initializers.RNCI(3),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Compute intermediate input and output sizes
|
# Compute intermediate input and output sizes
|
||||||
|
Loading…
Reference in New Issue
Block a user