Esempio n. 1
0
    def testComputeCovAgainstNumpy(self):
        with tf.Graph().as_default(), self.test_session() as sess:
            npr.seed(0)
            tf.set_random_seed(200)

            x = npr.randn(100, 3)
            cov = ff.compute_cov(tf.constant(x))
            np_cov = np.dot(x.T, x) / x.shape[0]

            self.assertAllClose(sess.run(cov), np_cov)
Esempio n. 2
0
    def testComputeCovAgainstNumpyWithAlternativeNormalizer(self):
        with tf.Graph().as_default(), self.test_session() as sess:
            npr.seed(0)
            tf.set_random_seed(200)

            normalizer = 10.
            x = npr.randn(100, 3)
            cov = ff.compute_cov(tf.constant(x), normalizer=normalizer)
            np_cov = np.dot(x.T, x) / normalizer

            self.assertAllClose(sess.run(cov), np_cov)