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


Python extensions.ExponentialShift方法代碼示例

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


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

示例1: setUp

# 需要導入模塊: from chainer.training import extensions [as 別名]
# 或者: from chainer.training.extensions import ExponentialShift [as 別名]
def setUp(self):
        self.optimizer = mock.MagicMock()
        self.extension = extensions.ExponentialShift(
            'x', self.rate, self.init, self.target, self.optimizer)

        self.interval = 4
        self.expect = [e for e in self.expect for _ in range(self.interval)]
        self.trigger = util.get_trigger((self.interval, 'iteration'))

        self.trainer = testing.get_trainer_with_mock_updater(self.trigger)
        self.trainer.updater.get_optimizer.return_value = self.optimizer 
開發者ID:chainer,項目名稱:chainer,代碼行數:13,代碼來源:test_exponential_shift.py

示例2: test_basic

# 需要導入模塊: from chainer.training import extensions [as 別名]
# 或者: from chainer.training.extensions import ExponentialShift [as 別名]
def test_basic(self):
        self.optimizer.x = 0
        extension = extensions.ExponentialShift(
            'x', self.rate, init=self.init, target=self.target)
        self._run_trainer(extension, self.expect) 
開發者ID:chainer,項目名稱:chainer,代碼行數:7,代碼來源:test_exponential_shift.py

示例3: test_without_init

# 需要導入模塊: from chainer.training import extensions [as 別名]
# 或者: from chainer.training.extensions import ExponentialShift [as 別名]
def test_without_init(self):
        self.optimizer.x = self.init
        extension = extensions.ExponentialShift(
            'x', self.rate, target=self.target)
        self._run_trainer(extension, self.expect) 
開發者ID:chainer,項目名稱:chainer,代碼行數:7,代碼來源:test_exponential_shift.py

示例4: test_with_optimizer

# 需要導入模塊: from chainer.training import extensions [as 別名]
# 或者: from chainer.training.extensions import ExponentialShift [as 別名]
def test_with_optimizer(self):
        optimizer = mock.Mock()
        optimizer.x = 0
        extension = extensions.ExponentialShift(
            'x', self.rate, init=self.init, target=self.target,
            optimizer=optimizer)
        self._run_trainer(extension, self.expect, optimizer) 
開發者ID:chainer,項目名稱:chainer,代碼行數:9,代碼來源:test_exponential_shift.py

示例5: test_resume

# 需要導入模塊: from chainer.training import extensions [as 別名]
# 或者: from chainer.training.extensions import ExponentialShift [as 別名]
def test_resume(self):
        new_optimizer = mock.Mock()
        new_extension = extensions.ExponentialShift(
            'x', self.rate, self.init, self.target, new_optimizer)

        self.trainer.extend(self.extension)
        self.trainer.run()

        new_trainer = testing.get_trainer_with_mock_updater((3, 'iteration'))
        new_trainer.extend(new_extension)
        testing.save_and_load_npz(self.trainer, new_trainer)

        new_extension.initialize(new_trainer)
        self.assertEqual(new_optimizer.x, self.optimizer.x)
        self.assertIsInstance(new_optimizer.x, float) 
開發者ID:chainer,項目名稱:chainer,代碼行數:17,代碼來源:test_exponential_shift.py


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