training.py
def train(self, X, Y, char2indexDict, vocabulary, config):
        """Trains the model with the desired data
        """

        print('Starting Training Phase...')
        start = datetime.datetime.now()
        self.model.compile(loss='categorical_crossentropy', optimizer='adam')

        # Due to the slowness of the learning we are using callbacks that saves weights to a file if an improvement in loss was achieved
        filename = str(self.config['training']['checkpoints']['foldername']) + '/weights-ep_{epoch:02d}-loss_{loss:.4f}.hdf5'
        callbackslist = [ModelCheckpoint(
            filename, monitor='loss', verbose=1, save_best_only=True, mode='min')]

        # epochs = Number of epochs to train the model (a single epoch is an iteration over the entire X and Y data)
        # batch-size = Number of samples per gradient update (faster for higher batch-sizes) default: 32
        # callbacks = List of Keras Callbacks to call while training (after each epoch)
        epochs_qty = self.config['training']['epochs_qty']
        batchsize = self.config['training']['gradient_batch_size']
        self.model.fit(X, Y, epochs=epochs_qty, batch_size=batchsize, callbacks=callbackslist)

        # As we are just predicting the next value, there is NO TEST DATA to evaluate against!

        end = datetime.datetime.now()
        deltaTime = end-start
        print('Training finished: %ds' % deltaTime.total_seconds())
        return self.model
Trains the model with the desired data
        
Trains the model with the desired data
Trains the model with the desired data
def train(self, X, Y, char2indexDict, vocabulary, config):
        print('Starting Training Phase...')
        start = datetime.datetime.now()
        self.model.compile(loss='categorical_crossentropy', optimizer='adam')
        filename = str(self.config['training']['checkpoints']['foldername']) + '/weights-ep_{epoch:02d}-loss_{loss:.4f}.hdf5'
        callbackslist = [ModelCheckpoint(
            filename, monitor='loss', verbose=1, save_best_only=True, mode='min')]
        epochs_qty = self.config['training']['epochs_qty']
        batchsize = self.config['training']['gradient_batch_size']
        self.model.fit(X, Y, epochs=epochs_qty, batch_size=batchsize, callbacks=callbackslist)
        end = datetime.datetime.now()
        deltaTime = end-start
        print('Training finished: %ds' % deltaTime.total_seconds())
        return self.model
def train ( self , X , Y , char2indexDict , vocabulary , config ) : print ( 'Starting Training Phase...' ) start = datetime . datetime . now ( ) self . model . compile ( loss = 'categorical_crossentropy' , optimizer = 'adam' ) filename = str ( self . config [ 'training' ] [ 'checkpoints' ] [ 'foldername' ] ) + '/weights-ep_{epoch:02d}-loss_{loss:.4f}.hdf5' callbackslist = [ ModelCheckpoint ( filename , monitor = 'loss' , verbose = 1 , save_best_only = True , mode = 'min' ) ] epochs_qty = self . config [ 'training' ] [ 'epochs_qty' ] batchsize = self . config [ 'training' ] [ 'gradient_batch_size' ] self . model . fit ( X , Y , epochs = epochs_qty , batch_size = batchsize , callbacks = callbackslist ) end = datetime . datetime . now ( ) deltaTime = end - start print ( 'Training finished: %ds' % deltaTime . total_seconds ( ) ) return self . model
Trains the model with the desired data
Trains the model with the desired data
"""Trains the model with the desired data
        """ # Due to the slowness of the learning we are using callbacks that saves weights to a file if an improvement in loss was achieved # epochs = Number of epochs to train the model (a single epoch is an iteration over the entire X and Y data) # batch-size = Number of samples per gradient update (faster for higher batch-sizes) default: 32 # callbacks = List of Keras Callbacks to call while training (after each epoch) # As we are just predicting the next value, there is NO TEST DATA to evaluate against!
self
X
Y
char2indexDict
vocabulary
config