From ac26499b38074ce2b2a94b2703f60faa9311036c Mon Sep 17 00:00:00 2001 From: Jeremy Gore Date: Wed, 23 Dec 2015 17:54:01 -0500 Subject: [PATCH] Fix bug when batch_size > dataset size If batch size is greater than the total size of the data set, no data will be yielded from _iterate_data. Consequently, no training will happen and you will get a ZeroDivision error for "loss / count" in _batch_impl. Also, it only generates batches of the exact size - any remaining data at the end is not trained on. --- sknn/backend/lasagne/mlp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sknn/backend/lasagne/mlp.py b/sknn/backend/lasagne/mlp.py index 6cbabf4..08a02fb 100644 --- a/sknn/backend/lasagne/mlp.py +++ b/sknn/backend/lasagne/mlp.py @@ -252,7 +252,7 @@ def cast(array): if shuffle: numpy.random.shuffle(indices) - for start_idx in range(0, total_size - batch_size + 1, batch_size): + for start_idx in range(0, total_size, batch_size): excerpt = indices[start_idx:start_idx + batch_size] Xb, yb, wb = cast(X[excerpt]), cast(y[excerpt]), None if w is not None: