Example #1
0
class TestCAE(unittest.TestCase):

    def setUp(self):
        self.model = CAE()
        self.optimizer = O.Adam()
        self.optimizer.setup(self.model)

        img = doll()
        x_data = np.array([im_to_blob(im_preprocess(img))])
        self.x = Variable(x_data)

    def test_train(self):
        self.optimizer.zero_grads()
        self.model.train = True
        self.optimizer.update(self.model, self.x)
        assert_is_not_none(self.model.z)
        assert_is_not_none(self.model.y)
        assert_is_not_none(self.model.loss)

    def test_encode(self):
        self.model.train = False
        self.model.encode(self.x)

    def test_decode(self):
        self.model.train = False
        h = self.model.encode(self.x)
        self.model.decode(h)
Example #2
0
    def setUp(self):
        self.model = CAE()
        self.optimizer = O.Adam()
        self.optimizer.setup(self.model)

        img = doll()
        x_data = np.array([im_to_blob(im_preprocess(img))])
        self.x = Variable(x_data)