@@ -0,0 +1,1697 @@
+import unittest%0A%0Aimport numpy%0A%0Aimport chainer%0Afrom chainer import links%0Afrom chainer.functions.evaluation import accuracy%0Afrom chainer import testing%0Afrom chainer.testing import attr%0A%0A%0Aclass accuracy_with_ignore_label(object):%0A%0A    def __call__(self, y, t):%0A        return accuracy.accuracy(y, t, ignore_label=1)%0A%0A%0A@testing.parameterize(*testing.product(%7B%0A    'evaluator': %5Baccuracy_with_ignore_label(), None%5D,%0A    'compute_accuracy': %5BTrue, False%5D%0A%7D))%0Aclass TestClassifier(unittest.TestCase):%0A%0A    def setUp(self):%0A        predictor = links.Linear(10, 3)%0A        if self.evaluator is None:%0A            self.link = links.Classifier(predictor)%0A        else:%0A            self.link = links.Classifier(predictor, evaluator=self.evaluator)%0A        self.link.compute_accuracy = self.compute_accuracy%0A%0A        self.x = numpy.random.uniform(-1, 1, (5, 10)).astype(numpy.float32)%0A        self.t = numpy.random.randint(3, size=(5)).astype(numpy.int32)%0A%0A    def check_call(self):%0A        xp = self.link.xp%0A        x = chainer.Variable(xp.asarray(self.x))%0A        t = chainer.Variable(xp.asarray(self.t))%0A        loss = self.link(x, t)%0A%0A        self.assertTrue(hasattr(self.link, 'y'))%0A        self.assertIsNotNone(self.link.y)%0A%0A        self.assertTrue(hasattr(self.link, 'loss'))%0A        xp.testing.assert_allclose(self.link.loss.data, loss.data)%0A%0A        self.assertTrue(hasattr(self.link, 'accuracy'))%0A        if self.compute_accuracy:%0A            self.assertIsNotNone(self.link.accuracy)%0A        else:%0A            self.assertIsNone(self.link.accuracy)%0A%0A    def test_call_cpu(self):%0A        self.check_call()%0A%0A    @attr.gpu%0A    def test_call_gpu(self):%0A        self.link.to_gpu()%0A        self.check_call()%0A

Add unittest to Classifier