Пример #1
0
    def testMakeCovarianceUpdateOpNoBias(self):
        with tf.Graph().as_default(), self.test_session() as sess:
            tf.set_random_seed(200)
            tensor = tf.constant([[1., 2.], [3., 4.]], name='a/b/c')
            factor = ff.FullyConnectedKroneckerFactor(((tensor, ), ))
            factor.instantiate_cov_variables()

            sess.run(tf.global_variables_initializer())
            new_cov = sess.run(factor.make_covariance_update_op(.5))
            self.assertAllClose([[3, 3.5], [3.5, 5.5]], new_cov)
Пример #2
0
 def _testFullyConnectedKroneckerFactorInit(self,
                                            has_bias,
                                            final_shape,
                                            dtype=dtypes.float32_ref):
     with tf.Graph().as_default():
         tf.set_random_seed(200)
         tensor = tf.ones((2, 3), dtype=dtype, name='a/b/c')
         factor = ff.FullyConnectedKroneckerFactor(((tensor, ), ),
                                                   has_bias=has_bias)
         factor.instantiate_cov_variables()
         cov = factor.cov
         self.assertEqual(cov.dtype, dtype)
         self.assertEqual(final_shape, cov.get_shape().as_list())