def testGetThrowsExceptionWithChildrenButNoMatch(self): var_name = 'parent/child' with self.test_session(): with tf.variable_scope(var_name): variables.variable('grandchild1', [7]) variables.variable('grandchild2', [9]) with self.assertRaises(ValueError): variables.get_unique_variable(var_name)
def testGetVariableWithDistractors(self): with self.test_session(): with tf.variable_scope('parent'): a = variables.variable('child', [5]) with tf.variable_scope('child'): variables.variable('grandchild1', [7]) variables.variable('grandchild2', [9]) self.assertEquals(a, variables.get_unique_variable('parent/child'))
def testGetVariableWithDistractors(self): with self.test_session(): with tf.variable_scope("parent"): a = variables.variable("child", [5]) with tf.variable_scope("child"): variables.variable("grandchild1", [7]) variables.variable("grandchild2", [9]) self.assertEquals(a, variables.get_unique_variable("parent/child"))
def testGetVariableThrowsExceptionWithNoMatch(self): var_name = 'cant_find_me' with self.test_session(): with self.assertRaises(ValueError): variables.get_unique_variable(var_name)
def testGetVariableWithSingleVar(self): with self.test_session(): with tf.variable_scope('parent'): a = variables.variable('child', [5]) self.assertEquals(a, variables.get_unique_variable('parent/child'))