Skip to content

Commit

Permalink
more tests added
Browse files Browse the repository at this point in the history
  • Loading branch information
JustGlowing committed May 3, 2024
1 parent f012e1f commit 5e09023
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions minisom.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,21 +114,20 @@ def __init__(self, x, y, input_len, sigma=1, learning_rate=0.5,
By default, at the iteration t, we have:
learning_rate(t) = learning_rate / (1 + t * (100 / max_iter))
decay_function : string or function, optional
decay_function : string or callable, optional
(default='inverse_decay_to_zero')
Function that reduces learning_rate at each iteration.
Possible values: 'inverse_decay_to_zero', 'linear_decay_to_zero',
'asymptotic_decay' or callable
If a custom decay function is passed
If a custom decay function using a callable
it will need to to take in input
three parameters in the following order:
1. learning rate
2. current iteration
3. maximum number of iterations allowed
Note that if a lambda function is used to define the decay
MiniSom will not be pickable anymore.
Expand Down Expand Up @@ -994,3 +993,9 @@ def test_decay_function_value(self):
MiniSom(5, 5, 2, decay_function='linear_decay_to_zero')
som1 = MiniSom(5, 5, 2, decay_function=lambda x, y, z: 1)
som1.train(random.rand(100, 2), 10)

def test_sigma_decay_function_value(self):
with self.assertRaises(ValueError):
MiniSom(5, 5, 2, sigma_decay_function='strawberry')
som1 = MiniSom(5, 5, 2, sigma_decay_function='linear_decay_to_one')
som1.train(random.rand(100, 2), 10)

0 comments on commit 5e09023

Please sign in to comment.