Ejemplo n.º 1
0
 def test_raw_spectral_norm(self):
     with tf.Graph().as_default():
         ones_weight = 4 * tf.eye(8, 8)
         sigma = spectral_normalization.spectral_norm(ones_weight)['sigma']
         with tf.Session() as sess:
             sess.run(tf.global_variables_initializer())
             _, sigma_v = sess.run([ones_weight, sigma])
             self.assertLess(abs(4.0 - sigma_v), _ACCEPTABLE_ERROR)
Ejemplo n.º 2
0
 def test_spectral_norm_creates_variables(self):
     with tf.Graph().as_default():
         ones_weight = 4 * tf.eye(8, 8)
         pre_spec_norm_vars = tf.global_variables()
         _ = spectral_normalization.spectral_norm(ones_weight)
         post_spec_norm_vars = tf.global_variables()
         self.assertEmpty(pre_spec_norm_vars)
         self.assertLen(post_spec_norm_vars, 1)
         self.assertEqual(post_spec_norm_vars[0].name.split('/')[-1],
                          'u0:0')