def __init__(self, search_space): search_config = {} search_config['learning_rate'] = ag.Real(1e-3, 1e-2, log=True) search_config['epochs'] = ag.Choice(40, 80) for config in search_config.keys(): if not config in search_space.keys(): search_space[config] = search_config[config] self.search_space = search_space
def __init__(self,dictionary_of_hyperparameters): search_config = {} search_config['learning_rate'] = ag.Real(1e-3, 1e-2, log=True) search_config['epochs'] = ag.Choice(40, 80) self.dictionary_of_hyperparameters = dictionary_of_hyperparameters for config in search_config.keys(): if not config in self.dictionary_of_hyperparameters .keys(): self.dictionary_of_hyperparameters [config] = search_config[config] self.dataset = dataset self.init_estimator = SimpleFeedForwardEstimator( num_hidden_dimensions=[10], prediction_length=dataset.metadata.prediction_length, context_length=100, freq=dataset.metadata.freq, trainer=Trainer(ctx="cpu", epochs=5, learning_rate=1e-3, num_batches_per_epoch=100 ) ) transformation = estimator.create_transformation() dtype = np.float32 num_workers = None num_prefetch = None shuffle_buffer_length = None trainer = Trainer(ctx="cpu", epochs=1, learning_rate=0.01, num_batches_per_epoch=100 ) self.training_data_loader = TrainDataLoader( dataset=dataset.train, transform=transformation, batch_size=trainer.batch_size, num_batches_per_epoch=trainer.num_batches_per_epoch, ctx=trainer.ctx, dtype=dtype, num_workers=num_workers, num_prefetch=num_prefetch, )
"""Train a BERT model using AutoGluon.""" import sys import autogluon as ag from bert_model import train_bert @ag.args( data_file=sys.argv[1], epochs=ag.Choice(40, 80), lr=ag.Real(1e-5, 1e-4, log=True), batch_size=ag.Choice(256, 512, 1024), wd=ag.Real(1e-3, 10, log=True), num_heads=ag.Choice(8, 16, 32, 64), num_pred_hiddens=ag.Choice(256, 512, 1024, 2048), ffn_num_hiddens=ag.Choice(512, 1024, 2048), num_layers=ag.Choice(6, 8, 12), dropout=ag.Real(1e-1, 8e-1, log=True), ) def run_training(args, reporter): """Launch training process.""" args.num_hiddens = args.num_heads return train_bert(args, reporter) def run(): """Run tuning.""" scheduler = ag.scheduler.FIFOScheduler(run_training, resource={ 'num_cpus': 1,
from asset import optimizer from gluonts.dataset.loader import TrainDataLoader from gluonts.trainer import Trainer with tqdm(training_data_loader) as it: for batch_no, data_entry in enumerate(it, start=1): if False: break inputs = [data_entry[k] for k in input_names] dictionary_of_hyperparameters = {} #dictionary_of_hyperparameters ['learning_rate'] = ag.Real(1e-3, 1e-2, log=True) dictionary_of_hyperparameters['epochs']=ag.Choice(10, 20) class auto: def __init__(self,dictionary_of_hyperparameters): search_config = {} search_config['learning_rate'] = ag.Real(1e-3, 1e-2, log=True) search_config['epochs'] = ag.Choice(40, 80) self.dictionary_of_hyperparameters = dictionary_of_hyperparameters for config in search_config.keys(): if not config in self.dictionary_of_hyperparameters .keys(): self.dictionary_of_hyperparameters [config] = search_config[config] self.dataset = dataset self.init_estimator = SimpleFeedForwardEstimator( num_hidden_dimensions=[10], prediction_length=dataset.metadata.prediction_length,