예제 #1
0
        def test(x):
            mu, sigma = preprocess.muSigma(x)

            self.assertAlmostEqual(1.23902738264240, x[1][2])

            self.assertEqual(5, len(mu))
            self.assertEqual(5, len(sigma))

            self.assertAlmostEqual(2.87969736221038, mu[0])
            self.assertAlmostEqual(2.04868506865762, sigma[0])
            self.assertAlmostEqual(-0.99025024303433, (x[0][0] - mu[0]) / sigma[0])

            self.assertAlmostEqual(1.97861578296198, mu[2])
            self.assertAlmostEqual(2.33076030134340, sigma[2])
            self.assertAlmostEqual(-0.31731637092553, (x[1][2] - mu[2]) / sigma[2])

            y = preprocess.normalize(x, mu, sigma)

            m, n = y.shape
            self.assertEqual(4, m)
            self.assertEqual(5, n)

            self.assertAlmostEqual(-0.99025024303433, y[0][0])
            self.assertAlmostEqual(-0.31731637092553, y[1][2])

            u = preprocess.sigmoid(y)
            self.assertAlmostEqual(0.27086265279957, u[0][0])
            self.assertAlmostEqual(0.42132990768430, u[1][2])
예제 #2
0
    def __init__(self, raw):
        train = self.mix(raw.train)
        test = self.mix(raw.test)
        valid = self.mix(raw.valid)

        self.mu, self.sigma = preprocess.muSigma(train[0])

        Dataset.__init__(self, self.normalize(train), 
                            self.normalize(valid),
                            self.normalize(test))