from utils.checkpoint import save_tagger_checkpoint from utils.device import get_device from utils.metric import AverageMeter, binary_accuracy from utils.optimizer import clip_gradient, adjust_learning_rate # Data parameters data_folder = './scn_data' # folder with data files saved by create_input_files.py # base name shared by data files data_name = 'flickr10k_5_cap_per_img_5_min_word_freq' # Model parameters semantic_size = 1000 dropout = 0.15 # sets device for model and PyTorch tensors device = get_device() # set to true only if inputs to model are fixed size; otherwise lot of computational overhead cudnn.benchmark = True # Training parameters start_epoch = 0 # number of epochs to train for (if early stopping is not triggered) epochs = 10 # keeps track of number of epochs since there's been an improvement in validation BLEU epochs_since_improvement = 0 batch_size = 32 adjust_lr_after_epoch = 4 fine_tune_encoder = False workers = 1 # for data-loading; right now, only 1 works with h5py encoder_lr = 1e-4 # learning rate for encoder if fine-tuning grad_clip = 5. # clip gradients at an absolute value of
} train_opts = { 'crit': 'MSELoss', #'MSELoss', #'BCELoss' for binary classification 'net': net_list[net_idx], 'optim': 'Adam', 'weight_decay': wd_list[wd_idx], 'optim_kwargs': {}, 'epochs': 15, 'lr': lr_list[lr_idx], 'milestones_perc': [1 / 3, 2 / 3], 'gamma': 0.1, 'train_batch_size': 31, 'test_batch_size': 31, 'device': get_device(), 'seed': 0, } results_opts = { 'training_results_path': './results', 'train_dump_file': 'training_results.json', } opts = dict(loader_opts, **net_opts) opts = dict(opts, **train_opts) opts = dict(opts, **results_opts) # these meters will be displayed to the console and saved into a csv stats_meter = { 'loss': lambda variables: float(variables['loss'].item()),