How to use keras.utils.Sequence with multiple files

I am looking at the documentation and this guide

https://www.tensorflow.org/api_docs/python/tf/keras/utils/Sequence

https://stanford.edu/~shervine/blog/keras-how-to-generate-data-on-the-fly

And I need to write in

def __len__(self):

and

def __getitem__(self, idx):

Which gets the length of the dataset, and the getting a data sample using a particular index. So I am wondering if this is appropriate to use for multiple files, and if so, are there any best practices for this?

Topic keras tensorflow

Category Data Science


The Sequence class from keras works great with multiple files. I've personally created a custom data generator using the Sequence class to load and pre-process multiple files. You should be able to figure it out using this post, I've found it to be very easy to follow the process of creating a custom data generator step by step.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.