Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added forced_even to BatchIterator ensure equal batch size #11

Merged
merged 1 commit into from
Dec 29, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion nolearn/lasagne.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ def negative_log_likelihood(output, prediction):


class BatchIterator(object):
def __init__(self, batch_size):
def __init__(self, batch_size, forced_even=False):
self.batch_size = batch_size
self.forced_even = forced_even

def __call__(self, X, y=None, test=False):
self.X, self.y = X, y
Expand All @@ -55,6 +56,8 @@ def __iter__(self):
for i in range((n_samples + bs - 1) / bs):
sl = slice(i * bs, (i + 1) * bs)
Xb = self.X[sl]
if self.forced_even and len(Xb) != bs:
continue
if self.y is not None:
yb = self.y[sl]
else:
Expand Down