Skip to content

Commit

Permalink
refined documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
JustGlowing committed Feb 25, 2022
1 parent a67b707 commit 4022fad
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions minisom.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ def __init__(self, x, y, input_len, sigma=1.0, learning_rate=0.5,
Distance used to activate the map.
Possible values: 'euclidean', 'cosine', 'manhattan', 'chebyshev'
Example of callable that can be passed:
def euclidean(x, w):
return linalg.norm(subtract(x, w), axis=-1)
random_seed : int, optional (default=None)
Random seed to use.
"""
Expand Down Expand Up @@ -797,11 +802,12 @@ def test_pickling(self):
os.remove('som.p')

def test_callable_activation_distance(self):
def eucledian(x, w):
def euclidean(x, w):
return linalg.norm(subtract(x, w), axis=-1)

data = random.rand(100, 2)
som1 = MiniSom(5, 5, 2, sigma=1.0, learning_rate=0.5, activation_distance=eucledian, random_seed=1)
som1 = MiniSom(5, 5, 2, sigma=1.0, learning_rate=0.5,
activation_distance=euclidean, random_seed=1)
som1.train_random(data, 10)
som2 = MiniSom(5, 5, 2, sigma=1.0, learning_rate=0.5, random_seed=1)
som2.train_random(data, 10)
Expand Down

0 comments on commit 4022fad

Please sign in to comment.