@@ -0,0 +1,1344 @@
+from __future__ import unicode_literals%0Afrom __future__ import print_function%0Afrom __future__ import division%0Afrom __future__ import absolute_import%0Afrom builtins import *  # NOQA%0Afrom future import standard_library%0Astandard_library.install_aliases()  # NOQA%0A%0Aimport unittest%0A%0Aimport chainer%0Aimport chainer.links as L%0Afrom chainer import testing%0Aimport numpy as np%0A%0Aimport chainerrl%0A%0A%0A@testing.parameterize(*testing.product(%0A    %7B%0A        'lr': %5B1.0, 0.1%5D,%0A        'weight_decay_rate': %5B0.1, 0.05%5D%0A    %7D%0A))%0Aclass TestNonbiasWeightDecay(unittest.TestCase):%0A%0A    def test(self):%0A%0A        model = chainer.Chain(%0A            a=L.Linear(1, 2, initialW=3, initial_bias=3),%0A            b=chainer.Chain(c=L.Linear(2, 3, initialW=4, initial_bias=4)),%0A        )%0A        optimizer = chainer.optimizers.SGD(self.lr)%0A        optimizer.setup(model)%0A        optimizer.add_hook(%0A            chainerrl.optimizers.NonbiasWeightDecay(%0A                rate=self.weight_decay_rate))%0A        optimizer.update(lambda: chainer.Variable(np.asarray(0.0)))%0A        decay_factor = 1 - self.lr * self.weight_decay_rate%0A        np.testing.assert_allclose(model.a.W.array, 3 * decay_factor)%0A        np.testing.assert_allclose(model.a.b.array, 3)%0A        np.testing.assert_allclose(model.b.c.W.array, 4 * decay_factor)%0A        np.testing.assert_allclose(model.b.c.b.array, 4)%0A

Add tests for NonbiasWeightDecay