Exemplo n.º 1
0
 def testL1RegularizerWithScope(self):
     with self.test_session():
         shape = [5, 5, 5]
         num_elem = 5 * 5 * 5
         tensor = tf.constant(1.0, shape=shape)
         loss = losses.l1_regularizer(scope='L1')(tensor)
         self.assertEqual(loss.op.name, 'L1/value')
         self.assertAlmostEqual(loss.eval(), num_elem, 5)
Exemplo n.º 2
0
 def testL1RegularizerWithScope(self):
   with self.test_session():
     shape = [5, 5, 5]
     num_elem = 5 * 5 * 5
     tensor = tf.constant(1.0, shape=shape)
     loss = losses.l1_regularizer(scope='L1')(tensor)
     self.assertEquals(loss.op.name, 'L1/value')
     self.assertAlmostEqual(loss.eval(), num_elem, 5)
Exemplo n.º 3
0
 def testL1RegularizerWithWeight(self):
     with self.test_session():
         shape = [5, 5, 5]
         num_elem = 5 * 5 * 5
         tensor = tf.constant(1.0, shape=shape)
         weight = 0.01
         loss = losses.l1_regularizer(weight)(tensor)
         self.assertEqual(loss.op.name, 'L1Regularizer/value')
         self.assertAlmostEqual(loss.eval(), num_elem * weight, 5)
Exemplo n.º 4
0
 def testL1RegularizerWithWeight(self):
   with self.test_session():
     shape = [5, 5, 5]
     num_elem = 5 * 5 * 5
     tensor = tf.constant(1.0, shape=shape)
     weight = 0.01
     loss = losses.l1_regularizer(weight)(tensor)
     self.assertEquals(loss.op.name, 'L1Regularizer/value')
     self.assertAlmostEqual(loss.eval(), num_elem * weight, 5)