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

Generator support? #7

Open
alex-jap opened this issue Dec 14, 2017 · 1 comment
Open

Generator support? #7

alex-jap opened this issue Dec 14, 2017 · 1 comment

Comments

@alex-jap
Copy link

Is there any possibility of using a generator in the data function for datasets that don't fit in memory? Keras' fit_generator method doesn't seem to be used anywhere.
Any suggestions on how this could be achieved?

@Avsecz
Copy link
Owner

Avsecz commented Dec 14, 2017

Hey, I started implementing it a while ago, but haven't finished due to time constraints. It's definitely something on my roadmap.

How this can be achieved?

The idea is to allow the data function to return a tuple of generators instead of loaded datasets:

import itertools 

def data_fn(a=1, b=10):
    def mygen(a):
        for i in range(a):
            yield i

    train = itertools.cycle(mygen(a))
    train.steps_per_epoch = a # pass the number of samples per epoch

    valid = itertools.cycle(mygen(b))
    valid.steps_per_epoch = b

    return train, valid

One would need to update the code at all the positions where model.predict, model.evaluate gets called with a conditional statement checking whether we are dealing with an iterator or a full dataset:

Feel free to send a PR in case you'd like to do it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants