當前位置: 首頁>>代碼示例>>Python>>正文


Python utility.make_optimizer方法代碼示例

本文整理匯總了Python中utility.make_optimizer方法的典型用法代碼示例。如果您正苦於以下問題:Python utility.make_optimizer方法的具體用法?Python utility.make_optimizer怎麽用?Python utility.make_optimizer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在utility的用法示例。


在下文中一共展示了utility.make_optimizer方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import utility [as 別名]
# 或者: from utility import make_optimizer [as 別名]
def __init__(self, args, loader, my_model, my_loss, ckp):
        self.args = args
        self.scale = args.scale

        self.ckp = ckp
        self.loader_train = loader.loader_train
        self.loader_test = loader.loader_test
        self.model = my_model
        self.loss = my_loss
        self.optimizer = utility.make_optimizer(args, self.model)
        self.scheduler = utility.make_scheduler(args, self.optimizer)

        if self.args.load != '':
            self.optimizer.load_state_dict(
                torch.load(os.path.join(ckp.dir, 'optimizer.pt'))
            )
            for _ in range(len(ckp.log)): self.scheduler.step()

        self.error_last = 1e8 
開發者ID:HolmesShuan,項目名稱:OISR-PyTorch,代碼行數:21,代碼來源:trainer.py

示例2: __init__

# 需要導入模塊: import utility [as 別名]
# 或者: from utility import make_optimizer [as 別名]
def __init__(self, args, gan_type):
        super(Adversarial, self).__init__()
        self.gan_type = gan_type
        self.gan_k = args.gan_k
        self.dis = discriminator.Discriminator(args)
        if gan_type == 'WGAN_GP':
            # see https://arxiv.org/pdf/1704.00028.pdf pp.4
            optim_dict = {
                'optimizer': 'ADAM',
                'betas': (0, 0.9),
                'epsilon': 1e-8,
                'lr': 1e-5,
                'weight_decay': args.weight_decay,
                'decay': args.decay,
                'gamma': args.gamma
            }
            optim_args = SimpleNamespace(**optim_dict)
        else:
            optim_args = args

        self.optimizer = utility.make_optimizer(optim_args, self.dis) 
開發者ID:thstkdgus35,項目名稱:EDSR-PyTorch,代碼行數:23,代碼來源:adversarial.py

示例3: __init__

# 需要導入模塊: import utility [as 別名]
# 或者: from utility import make_optimizer [as 別名]
def __init__(self, args, loader, my_model, my_loss, ckp):
        self.args = args
        self.scale = args.scale

        self.ckp = ckp
        self.loader_train = loader.loader_train
        self.loader_test = loader.loader_test
        self.model = my_model
        self.loss = my_loss
        self.optimizer = utility.make_optimizer(args, self.model)
        self.scheduler = utility.make_scheduler(args, self.optimizer)

        if self.args.load != '.':
            self.optimizer.load_state_dict(
                torch.load(os.path.join(ckp.dir, 'optimizer.pt'))
            )
            for _ in range(len(ckp.log)): self.scheduler.step()

        self.error_last = 1e8 
開發者ID:ofsoundof,項目名稱:3D_Appearance_SR,代碼行數:21,代碼來源:trainer.py

示例4: __init__

# 需要導入模塊: import utility [as 別名]
# 或者: from utility import make_optimizer [as 別名]
def __init__(self, args, loader, my_model, my_loss, ckp):
        self.args = args
        self.scale = args.scale

        self.ckp = ckp
        self.loader_train = loader.loader_train
        self.loader_test = loader.loader_test
        self.model = my_model
        self.loss = my_loss
        self.optimizer = utility.make_optimizer(args, self.model)
        self.scheduler = utility.make_scheduler(args, self.optimizer)

        if self.args.load != '.':
            self.optimizer.load_state_dict(
                torch.load(os.path.join(ckp.dir, 'optimizer.pt'))
            )
            for _ in range(len(ckp.log)): self.scheduler.step()

        self.error_last = 1e8
        del args,ckp,my_model,my_loss 
開發者ID:yyknight,項目名稱:NTIRE2019_EDRN,代碼行數:22,代碼來源:trainer.py

示例5: __init__

# 需要導入模塊: import utility [as 別名]
# 或者: from utility import make_optimizer [as 別名]
def __init__(self, args, gan_type):
        super(Adversarial, self).__init__()
        self.gan_type = gan_type
        self.gan_k = args.gan_k
        self.discriminator = discriminator.Discriminator(args, gan_type)
        if gan_type != 'WGAN_GP':
            self.optimizer = utility.make_optimizer(args, self.discriminator)
        else:
            self.optimizer = optim.Adam(
                self.discriminator.parameters(),
                betas=(0, 0.9), eps=1e-8, lr=1e-5
            )
        self.scheduler = utility.make_scheduler(args, self.optimizer) 
開發者ID:HolmesShuan,項目名稱:OISR-PyTorch,代碼行數:15,代碼來源:adversarial.py

示例6: __init__

# 需要導入模塊: import utility [as 別名]
# 或者: from utility import make_optimizer [as 別名]
def __init__(self, args, loader, my_model, my_loss, ckp):
        self.args = args
        self.scale = args.scale

        self.ckp = ckp
        self.loader_train = loader.loader_train
        self.loader_test = loader.loader_test
        self.model = my_model
        self.loss = my_loss
        self.optimizer = utility.make_optimizer(args, self.model)

        if self.args.load != '':
            self.optimizer.load(ckp.dir, epoch=len(ckp.log))

        self.error_last = 1e8 
開發者ID:thstkdgus35,項目名稱:EDSR-PyTorch,代碼行數:17,代碼來源:trainer.py


注:本文中的utility.make_optimizer方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。