dnouri/nolearn

TrainSplit(eval_size=0.0) and BatchIterator(shuffle=True) crashes

jrodrigog opened this issue · 1 comments

Hello. I have a little glitch here, when setting eval_size to 0 on the TrainSplit object nolearn only works if the validation BatchIterator has shuffle equal to False (the default).

Traceback (most recent call last):
  File "./test_dnn2.py", line 569, in <module>
    main()
  File "./test_dnn2.py", line 562, in main
    nn.fit(x, y)
  File "./test_dnn2.py", line 262, in fit
    self.net.fit(x, y)
  File "/usr/lib64/python3.4/site-packages/nolearn/lasagne/base.py", line 674, in fit
    self.train_loop(X, y, epochs=epochs)
  File "/usr/lib64/python3.4/site-packages/nolearn/lasagne/base.py", line 744, in train_loop
    for Xb, yb in self.batch_iterator_test(X_valid, y_valid):
  File "/usr/lib64/python3.4/site-packages/nolearn/lasagne/base.py", line 78, in __call__
    self._shuffle_arrays([X, y] if y is not None else [X], self.random)
  File "/usr/lib64/python3.4/site-packages/nolearn/lasagne/base.py", line 103, in _shuffle_arrays
    random.shuffle(array)
  File "mtrand.pyx", line 4656, in mtrand.RandomState.shuffle (numpy/random/mtrand/mtrand.c:30146)
IndexError: index 0 is out of bounds for axis 0 with size 0

Forgetting to change shuffle to False on the BatchIterator crashes.
Tested with nolearn-0.6.1.dev0.

Try upgrading nolearn to version 0.7

Command:

sudo pip3 install --upgrade --no-deps --force-reinstall git+https://github.com/dnouri/nolearn.git@master#egg=nolearn==0.7.git

If that fails try this workaround...

Try:

eval_size = 0.01