Comments (3)
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.
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.
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)
- To Keras community: What interpretations do you have for these curves? HOT 3
- No module named 'keras.src.engine' HOT 7
- Feature request: keras.ops.linalg.lstsq HOT 4
- Example Doubt HOT 3
- More Customisation in utils.ProgBar HOT 6
- Progress bar crash when empty dataset HOT 1
- Multihead Attention Seed Specification HOT 1
- Unable to make two instances of the MobileNetV3 within the same model HOT 2
- NumPy 2.0 support HOT 3
- Add backend-agnostic worker-process data loading HOT 8
- Keras does not save weights properly HOT 2
- Potential bug in legacy h5 weights loading. HOT 2
- Enable Discussions Tab in Github HOT 1
- FeatureSpace multiple output from one input HOT 3
- `keras.Sequential` sometimes states misleading reason for failing to construct model HOT 2
- Implement tool for saved Keras model file inspection, diff, and patching. HOT 5
- Request for a map function like map_fn in TF and vmap in Jax HOT 5
- AttributeError raised: 'list' object has no attribute 'dtype' when running the official example of SparseCategoricalAccuracy, TopKCategoricalAccuracy, SparseTopKCategoricalAccuracy HOT 2
- ValueError: (F1Score|FBetaScore) expects 2D inputs with shape (batch_size, output_dim).
- `plot_model` does not work for all models in `keras.applications` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from keras.