Using the keras sequential utils as generator

Keras has a good batch generator named keras.utils.sequence() that helps you customize batch creation with great flexibility. In fact, with keras.utils.sequence() one can design the whole epoch pipeline. We are going to use this utility in this regression problem to get accustomed to this utility. For the transfer learning problem we can design a generator class using keras.utils.sequence() as follows:

class DataGenerator(keras.utils.Sequence):    'Generates data for Keras'    def __init__(self,files,labels,batch_size=32,n_classes=5,dim=(224,224,3),shuffle=True):        'Initialization'        self.labels = labels        self.files = files        self.batch_size = batch_size        self.n_classes = n_classes        self.dim = dim self.shuffle ...

Get Intelligent Projects Using Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.