def build_optim(model): optim = Optim(config.optim_method, config.lr, config.max_grad_norm, config.learning_rate_decay, config.weight_decay, config.start_decay_at) optim.set_parameters(model.parameters()) return optim
def build_sampler_optim(model, config): optim = Optim(config['Seq2SeqWithRL']['Trainer']['optim_method'], config['Seq2SeqWithRL']['Trainer']['sampler_lr'], config['Seq2SeqWithRL']['Trainer']['max_grad_norm'], config['Seq2SeqWithRL']['Trainer']['learning_rate_decay'], config['Seq2SeqWithRL']['Trainer']['weight_decay'], config['Seq2SeqWithRL']['Trainer']['start_decay_at']) optim.set_parameters(model.parameters()) return optim