Exemple #1
0
    def setUp(self):
        y_shape = self.y_shape
        x_shape = self.x_shape
        y1 = make_array(1, y_shape, numpy.float32)
        y2 = make_array(2, y_shape, numpy.float32)
        gx1 = make_array(1, x_shape, numpy.float32)
        gx2 = None
        gy1 = make_array(1, y_shape, numpy.float32)
        gy2 = make_array(1, y_shape, numpy.float32)

        f = chainer.Function()
        f.check_type_forward = mock.MagicMock()
        f.forward_cpu = mock.MagicMock(return_value=(y1, y2))
        f.forward_gpu = mock.MagicMock()
        f.backward_cpu = mock.MagicMock(return_value=(gx1, gx2))
        f.backward_gpu = mock.MagicMock()
        self.f = f

        self.x1 = make_array(0, x_shape, numpy.float32)
        self.x2 = make_array(0, x_shape, numpy.int32)
        self.y1 = y1
        self.y2 = y2
        self.gx1 = gx1
        self.gx2 = gx2
        self.gy1 = gy1
        self.gy2 = gy2
Exemple #2
0
 def test_set_fresh_creator(self):
     v = chainer.Variable()
     f = chainer.Function()
     v.creator = f
     self.assertIs(v.creator, f)
     self.assertIs(v.creator_node, f.node)
     self.assertEqual(v.rank, 1)
 def setUp(self):
     f = chainer.Function()
     f.p1 = numpy.arange(10)
     f.p2 = numpy.arange(5)
     f.g1 = numpy.arange(8)
     f.g2 = numpy.arange(3)
     f.parameter_names = ('p1', 'p2')
     f.gradient_names = ('g1', 'g2')
     self.f = f
    def setUp(self):
        y1 = numpy.arange(4).astype(numpy.float32)
        y2 = numpy.arange(4).astype(numpy.float32) + 1
        gx1 = numpy.arange(3).astype(numpy.float32)
        gx2 = None
        gy1 = numpy.arange(4).astype(numpy.float32)
        gy2 = numpy.arange(4).astype(numpy.float32)

        f = chainer.Function()
        f.check_type_forward = mock.MagicMock()
        f.forward_cpu = mock.MagicMock(return_value=(y1, y2))
        f.forward_gpu = mock.MagicMock()
        f.backward_cpu = mock.MagicMock(return_value=(gx1, gx2))
        f.backward_gpu = mock.MagicMock()
        self.f = f

        self.x1 = numpy.arange(3).astype(numpy.float32)
        self.x2 = numpy.arange(3).astype(numpy.int32)
        self.y1 = y1
        self.y2 = y2
        self.gx1 = gx1
        self.gx2 = gx2
        self.gy1 = gy1
        self.gy2 = gy2
 def setUp(self):
     self.original_debug = chainer.is_debug()
     chainer.set_debug(True)
     self.one = numpy.array([1], numpy.float32)
     self.f = chainer.Function()
Exemple #6
0
 def test_label(self):
     self.assertEqual(chainer.Function().label, 'Function')
Exemple #7
0
 def test_label(self):
     self.assertEqual(chainer.Function().label,
                      '<class \'chainer.function.Function\'>')