Exemplo n.º 1
0
    def setup_model(self):
        self.train_loss = AverageMeter()
        self.network = ConvQA_CN_Net(self.opt, self.dev_lang)
        if self.use_cuda:
            self.log('Using GPU to setup model...')
            self.network.cuda()
        parameters = [p for p in self.network.parameters() if p.requires_grad]

        ## Ranger优化器
        self.optimizer = Ranger(parameters)
        # self.optimizer = AdamW(parameters, lr=3e-5, weight_decay=0.01)
        self.updates = 0
        self.epoch_start = 0
Exemplo n.º 2
0
    def setup_model(self, vocab_embedding):
        self.train_loss = AverageMeter()
        self.network = SDNet(self.opt, vocab_embedding)
        if self.use_cuda:
            self.log('Putting model into GPU')
            self.network.cuda()

        parameters = [p for p in self.network.parameters() if p.requires_grad]
        self.optimizer = optim.Adamax(parameters)
        if 'ADAM2' in self.opt:
            print('ADAM2')
            self.optimizer = optim.Adam(parameters, lr=0.0001)

        self.updates = 0
        self.epoch_start = 0
        self.loss_func = F.cross_entropy