def train_model(self): # train a model model, optimizer, stats_dictionary = train(self.train_file, self.test_file, self.batch_size, self.epochs, self.gpu_mode, self.num_workers, self.retrain_model, self.retrain_model_path, self.gru_layers, self.hidden_size, self.learning_rate, self.weight_decay, self.model_dir, self.stats_dir, train_mode=True) return model, optimizer, stats_dictionary
def try_params(self, n_iterations, model_params, model_path): """ Try a parameter space to train a model with n_iterations (epochs). :param n_iterations: Number of epochs to train on :param model_params: Parameter space :return: trained model, optimizer and stats dictionary (loss and others) """ # Number of iterations or epoch for the model to train on n_iterations = int(round(n_iterations)) params, retrain_model, retrain_model_path, prev_ite = model_params sys.stderr.write(TextColor.BLUE + '\nEpochs: ' + str(n_iterations) + "\n" + TextColor.END) sys.stderr.write(TextColor.BLUE + str(params) + "\n" + TextColor.END) epoch_limit = int(n_iterations) enc_lr = params['encoder_lr'] enc_l2 = params['encoder_l2'] dec_lr = params['decoder_lr'] dec_l2 = params['decoder_l2'] # train a model enc_model, dec_model, enc_optimizer, dec_optimizer, stats_dictionary = train(self.train_file, self.test_file, self.batch_size, epoch_limit, self.gpu_mode, self.num_workers, retrain_model, retrain_model_path, self.gru_layers, self.hidden_size, enc_lr, enc_l2, dec_lr, dec_l2, model_dir=None, stats_dir=None, train_mode=False) save_best_model(enc_model, dec_model, enc_optimizer, dec_optimizer, self.hidden_size, self.gru_layers, epoch_limit, model_path) return enc_model, dec_model, enc_optimizer, dec_optimizer, stats_dictionary
def train_model(self): # train a model enc_model, dec_model, enc_optimizer, dec_optimizer, stats_dictionary = train( self.train_file, self.test_file, self.batch_size, self.epochs, self.gpu_mode, self.num_workers, self.retrain_model, self.retrain_model_path, self.gru_layers, self.hidden_size, self.encoder_lr, self.encoder_l2, self.decoder_lr, self.decoder_l2, self.model_dir, self.stats_dir, train_mode=True) return enc_model, dec_model, enc_optimizer, dec_optimizer, stats_dictionary