def test_stable_global_norm_unchanged(self):
"""Test that preconditioning doesn't change global norm value."""
tf.set_random_seed(1234)
tensors = [tf.random_uniform(
[3] * i, -10.0, 10.0) for i in range(6)]
gnorm = tf.global_norm(tensors)
precond_gnorm = tfgan_losses._numerically_stable_global_norm(tensors)
with self.test_session(use_gpu=True) as sess:
# spot check closeness on more than one sample.
for _ in range(10):
gnorm_np, precond_gnorm_np = sess.run([gnorm, precond_gnorm])
self.assertNear(gnorm_np, precond_gnorm_np, 1e-5)
评论列表
文章目录