Skip to content
This repository has been archived by the owner on Jul 10, 2021. It is now read-only.

Commit

Permalink
Warning if no iterations or validation set specified.
Browse files Browse the repository at this point in the history
Closes #104.
  • Loading branch information
alexjc committed Nov 17, 2015
1 parent fc9142b commit 58fcb3c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sknn/mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ def _reshape(self, X, y=None):
return X, y

def _train(self, X, y):
assert self.n_iter or self.valid_set,\
"Neither n_iter nor valid_set were specified; training would loop forever."

best_train_error, best_valid_error = float("inf"), float("inf")
stable = 0

Expand Down
5 changes: 5 additions & 0 deletions sknn/tests/test_training.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ def test_FitAutomaticValidation(self):
valid_size=0.25)

self.nn._fit(a_in, a_out)

def test_TrainingInfinite(self):
a_in, a_out = numpy.zeros((8,16)), numpy.zeros((8,4))
self.nn = MLP(layers=[L("Linear")])
assert_raises(AssertionError, self.nn._fit, a_in, a_out)


class TestCustomLogging(unittest.TestCase):
Expand Down

0 comments on commit 58fcb3c

Please sign in to comment.