GithubHelp home page GithubHelp logo

Support Infinite PyDataset about keras HOT 3 CLOSED

LarsKue avatar LarsKue commented on May 18, 2024
Support Infinite PyDataset

from keras.

Comments (3)

fchollet avatar fchollet commented on May 18, 2024

There are two separate issues here: support for infinite cardinality, and support for dynamically sized batches.

For infinite cardinality support, we can use None to indicate it. We can definitely support it, similar to what we do for infinite tf.data.Dataset instances. If you're able, feel free to open a PR!

from keras.

LarsKue avatar LarsKue commented on May 18, 2024

Yes, I felt the two issues are similar enough to group them in one issue. Apologies if this is not how you see it.

As for returning None as the length, I feel this is a little risky, since forgetting a return statement also looks like returning None from the outside. This could be an issue for a dataset that has a more complex length computation, such as one that increases in length as training goes on (e.g. experience replay buffers).

from keras.

hertschuh avatar hertschuh commented on May 18, 2024

Hi @LarsKue ,

Thank you for reporting this.

For item 2., this is already how it works. __getitem__ returns a full batch, and the batch size can be different from batch to batch.

For item 1. I just pushed a change that enables this. You implement the num_batches property and return None to signal an infinite dataset. I understand the concern that if you forget a return clause, you could return None by accident. But weighing this against other options, it seemed relatively less error prone (you could easily do incorrect math with -1).

Note that you can also easily feed a infinite dataset to model.fit() by using a generator.

def generate():
    while True:
        x = ...
        y = ...
        yield x, y

model.fit(generate(), ...)

It's less code than implementing a PyDataset and doesn't require being able to access your data by index. However, it doesn't support multiprocessing / multithreading.

from keras.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.