in src/trainer.py [0:0]
def __init__(self, config, net, dataset):
'''
:param config: a dict containing parameters
:param net: the network to be trained, must be of type src.utils.Net
:param dataset: the dataset to be trained on
'''
self.config = config
self.dataset = dataset
self.dataloader = DataLoader(dataset, batch_size=config["batch_size"], shuffle=True, num_workers=1)
gpus = [i for i in range(config["num_gpus"])]
self.net = th.nn.DataParallel(net, gpus)
weights = filter(lambda x: x.requires_grad, net.parameters())
self.optimizer = NewbobAdam(weights,
net,
artifacts_dir=config["artifacts_dir"],
initial_learning_rate=config["learning_rate"],
decay=config["newbob_decay"],
max_decay=config["newbob_max_decay"])
self.l2_loss = L2Loss(mask_beginning=config["mask_beginning"])
self.phase_loss = PhaseLoss(sample_rate=48000, mask_beginning=config["mask_beginning"])
self.total_iters = 0
# switch to training mode
self.net.train()