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

Fix initialization of index_array #2590

Merged
merged 1 commit into from
May 7, 2016
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 keras/preprocessing/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,12 @@ def reset(self):
self.batch_index = 0

def _flow_index(self, N, batch_size=32, shuffle=False, seed=None):
# ensure self.batch_index is 0
self.reset()
Copy link
Contributor Author

@henry0312 henry0312 May 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

index_array is ALWAYS initialized whenever _flow_index is called, so some indexes may not be used 😢

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to make reset() in flow() superfluous. If so I think it would be cleaner and still safe to just remove the reset() from flow and have the index_array generator handle resetting all its counters.


while 1:
index_array = np.arange(N)
if self.batch_index == 0:
index_array = np.arange(N)
if shuffle:
if seed is not None:
np.random.seed(seed + self.total_batches_seen)
Expand Down