def on_train_end(self, logs=None): if self.stopped_epoch > 0: logging.info('Epoch %05d: early stopping', self.stopped_epoch + 1) try: from cnn import semantic_similarity_layer, ranking_loss from keras.models import load_model self.model = load_model(self.model_path, custom_objects={ 'semantic_similarity_layer': semantic_similarity_layer, 'ranking_loss': ranking_loss }) except OSError: pass predict(self.conf, self.concept, self.positives, self.vocab, self.entity_model, self.concept_model, self.model, self.val_data, result=self.history) if self.conf.getint('model', 'save'): callback.save_model(self.model, self.conf['model']['path'], self.now) return
def on_train_end(self, logs=None): if self.stopped_epoch > 0: logger.info('Epoch %05d: early stopping', self.stopped_epoch + 1) try: self.original_model.load_weights(self.model_path) logger.info('Best model reloaded.') except OSError: pass predict(self.conf, self.concept, self.positives, self.vocab, self.entity_model, self.concept_model,self.original_model, self.val_data, result=self.history) if self.conf.getint('model','save'): callback.save_model(self.original_model, self.conf['model']['path'],self.now) return