Exemple #1
0
 def test_create_variable_scope(self):
     with tf.variable_scope('foo'):
         self.assertEqual('foo/bar', tdl.create_variable_scope('bar').name)
         with tf.variable_scope('/'):
             pass
         # tf.variable_scope pushes a new name scope internally, so
         # creating variable scope 'foo/bar' when name scope /foo/bar/
         # already exists has the side-effect of creating name scope
         # /foo/bar_1', so the numbering skips to 2 here.
         self.assertEqual('foo/bar_2',
                          tdl.create_variable_scope('bar').name)
         self.assertEqual('foo/bar/',
                          tdl.create_variable_scope('bar/').name)
         self.assertEqual('foo/bar/',
                          tdl.create_variable_scope('bar/').name)
         self.assertEqual('foo//', tdl.create_variable_scope('/').name)
     with tf.variable_scope('foo'):
         self.assertEqual('foo/bar_3',
                          tdl.create_variable_scope('bar').name)
     self.assertEqual('foo/bar_4',
                      tdl.create_variable_scope('foo/bar').name)
     self.assertEqual('foo/', tdl.create_variable_scope('foo/').name)
     self.assertEqual('foo/', tdl.create_variable_scope('foo/').name)
Exemple #2
0
 def test_create_variable_scope2(self):
     with tf.variable_scope('outer'):
         with tf.variable_scope('inner'):
             pass
         self.assertEqual('outer/inner_1',
                          tdl.create_variable_scope('inner').name)