def testTrue(self): ff.set_global_constants(colocate_cov_ops_with_inputs=True) with tf_ops.Graph().as_default(): a = constant_op.constant([2.0], name='a') with ff.maybe_colocate_with(a): b = constant_op.constant(3.0, name='b') self.assertEqual([b'loc:@a'], a.op.colocation_groups()) self.assertEqual([b'loc:@a'], b.op.colocation_groups())
from tensorflow.contrib.kfac.python.ops import fisher_factors as ff from tensorflow.contrib.kfac.python.ops import layer_collection as lc from tensorflow.contrib.kfac.python.ops import optimizer from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import init_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import nn from tensorflow.python.ops import variable_scope from tensorflow.python.ops import variables as tf_variables from tensorflow.python.platform import test # We need to set these constants since the numerical values used in the tests # were chosen when these used to be the defaults. ff.set_global_constants(init_covariances_at_zero=False, zero_debias=False, init_inverses_at_zero=False) def dummy_layer_collection(): lcoll = lc.LayerCollection() dummy = array_ops.constant([1., 2.]) lcoll.register_categorical_predictive_distribution(logits=dummy) return lcoll class OptimizerTest(test.TestCase): def testOptimizerInitInvalidMomentumRegistration(self): with self.assertRaises(ValueError): optimizer.KfacOptimizer(0.1, 0.2,
from tensorflow.contrib.kfac.python.ops import layer_collection as lc from tensorflow.contrib.kfac.python.ops import optimizer from tensorflow.python.framework import ops from tensorflow.python.ops import array_ops from tensorflow.python.ops import init_ops from tensorflow.python.ops import math_ops from tensorflow.python.ops import nn from tensorflow.python.ops import variable_scope from tensorflow.python.ops import variables as tf_variables from tensorflow.python.platform import test # We need to set these constants since the numerical values used in the tests # were chosen when these used to be the defaults. ff.set_global_constants(init_covariances_at_zero=False, zero_debias=False, init_inverses_at_zero=False) def dummy_layer_collection(): lcoll = lc.LayerCollection() dummy = array_ops.constant([1., 2.]) lcoll.register_categorical_predictive_distribution(logits=dummy) return lcoll class OptimizerTest(test.TestCase): def testOptimizerInitInvalidMomentumRegistration(self): with self.assertRaises(ValueError): optimizer.KfacOptimizer(
def tearDown(self): ff.set_global_constants( colocate_cov_ops_with_inputs=self._colocate_cov_ops_with_inputs)