本文整理汇总了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
示例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)
示例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)
示例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)
示例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)