当前位置: 首页>>代码示例>>Python>>正文


Python variables.get_variables方法代码示例

本文整理汇总了Python中inception.slim.variables.get_variables方法的典型用法代码示例。如果您正苦于以下问题:Python variables.get_variables方法的具体用法?Python variables.get_variables怎么用?Python variables.get_variables使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在inception.slim.variables的用法示例。


在下文中一共展示了variables.get_variables方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testGetVariables

# 需要导入模块: from inception.slim import variables [as 别名]
# 或者: from inception.slim.variables import get_variables [as 别名]
def testGetVariables(self):
    with self.test_session():
      with tf.variable_scope('A'):
        a = variables.variable('a', [5])
      with tf.variable_scope('B'):
        b = variables.variable('a', [5])
      self.assertEquals([a, b], variables.get_variables())
      self.assertEquals([a], variables.get_variables('A'))
      self.assertEquals([b], variables.get_variables('B')) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:11,代码来源:variables_test.py

示例2: testGetVariablesSuffix

# 需要导入模块: from inception.slim import variables [as 别名]
# 或者: from inception.slim.variables import get_variables [as 别名]
def testGetVariablesSuffix(self):
    with self.test_session():
      with tf.variable_scope('A'):
        a = variables.variable('a', [5])
      with tf.variable_scope('A'):
        b = variables.variable('b', [5])
      self.assertEquals([a], variables.get_variables(suffix='a'))
      self.assertEquals([b], variables.get_variables(suffix='b')) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:10,代码来源:variables_test.py

示例3: testNoneGetVariablesToRestore

# 需要导入模块: from inception.slim import variables [as 别名]
# 或者: from inception.slim.variables import get_variables [as 别名]
def testNoneGetVariablesToRestore(self):
    with self.test_session():
      with tf.variable_scope('A'):
        a = variables.variable('a', [5], restore=False)
      with tf.variable_scope('B'):
        b = variables.variable('a', [5], restore=False)
      self.assertEquals([], variables.get_variables_to_restore())
      self.assertEquals([a, b], variables.get_variables()) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:10,代码来源:variables_test.py

示例4: testGetMixedVariablesToRestore

# 需要导入模块: from inception.slim import variables [as 别名]
# 或者: from inception.slim.variables import get_variables [as 别名]
def testGetMixedVariablesToRestore(self):
    with self.test_session():
      with tf.variable_scope('A'):
        a = variables.variable('a', [5])
        b = variables.variable('b', [5], restore=False)
      with tf.variable_scope('B'):
        c = variables.variable('c', [5])
        d = variables.variable('d', [5], restore=False)
      self.assertEquals([a, b, c, d], variables.get_variables())
      self.assertEquals([a, c], variables.get_variables_to_restore()) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:12,代码来源:variables_test.py

示例5: testReuseVariable

# 需要导入模块: from inception.slim import variables [as 别名]
# 或者: from inception.slim.variables import get_variables [as 别名]
def testReuseVariable(self):
    with self.test_session():
      with tf.variable_scope('A'):
        a = variables.variable('a', [])
      with tf.variable_scope('A', reuse=True):
        b = variables.variable('a', [])
      self.assertEquals(a, b)
      self.assertListEqual([a], variables.get_variables()) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:10,代码来源:variables_test.py

示例6: testReuseVars

# 需要导入模块: from inception.slim import variables [as 别名]
# 或者: from inception.slim.variables import get_variables [as 别名]
def testReuseVars(self):
    height, width = 3, 3
    with self.test_session():
      images = tf.random_uniform((5, height, width, 3), seed=1)
      ops.conv2d(images, 32, [3, 3], scope='conv1')
      self.assertEquals(len(variables.get_variables()), 2)
      ops.conv2d(images, 32, [3, 3], scope='conv1', reuse=True)
      self.assertEquals(len(variables.get_variables()), 2) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:10,代码来源:ops_test.py

示例7: testNonReuseVars

# 需要导入模块: from inception.slim import variables [as 别名]
# 或者: from inception.slim.variables import get_variables [as 别名]
def testNonReuseVars(self):
    height, width = 3, 3
    with self.test_session():
      images = tf.random_uniform((5, height, width, 3), seed=1)
      ops.conv2d(images, 32, [3, 3])
      self.assertEquals(len(variables.get_variables()), 2)
      ops.conv2d(images, 32, [3, 3])
      self.assertEquals(len(variables.get_variables()), 4) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:10,代码来源:ops_test.py

示例8: testReuseConvWithWD

# 需要导入模块: from inception.slim import variables [as 别名]
# 或者: from inception.slim.variables import get_variables [as 别名]
def testReuseConvWithWD(self):
    height, width = 3, 3
    with self.test_session():
      images = tf.random_uniform((5, height, width, 3), seed=1)
      ops.conv2d(images, 32, [3, 3], weight_decay=0.01, scope='conv1')
      self.assertEquals(len(variables.get_variables()), 2)
      self.assertEquals(
          len(tf.get_collection(tf.GraphKeys.REGULARIZATION_LOSSES)), 1)
      ops.conv2d(images, 32, [3, 3], weight_decay=0.01, scope='conv1',
                 reuse=True)
      self.assertEquals(len(variables.get_variables()), 2)
      self.assertEquals(
          len(tf.get_collection(tf.GraphKeys.REGULARIZATION_LOSSES)), 1) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:15,代码来源:ops_test.py

示例9: testConvWithBatchNorm

# 需要导入模块: from inception.slim import variables [as 别名]
# 或者: from inception.slim.variables import get_variables [as 别名]
def testConvWithBatchNorm(self):
    height, width = 3, 3
    with self.test_session():
      images = tf.random_uniform((5, height, width, 32), seed=1)
      with scopes.arg_scope([ops.conv2d], batch_norm_params={'decay': 0.9}):
        net = ops.conv2d(images, 32, [3, 3])
        net = ops.conv2d(net, 32, [3, 3])
      self.assertEquals(len(variables.get_variables()), 8)
      self.assertEquals(len(variables.get_variables('Conv/BatchNorm')), 3)
      self.assertEquals(len(variables.get_variables('Conv_1/BatchNorm')), 3) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:12,代码来源:ops_test.py

示例10: testReuseConvWithBatchNorm

# 需要导入模块: from inception.slim import variables [as 别名]
# 或者: from inception.slim.variables import get_variables [as 别名]
def testReuseConvWithBatchNorm(self):
    height, width = 3, 3
    with self.test_session():
      images = tf.random_uniform((5, height, width, 32), seed=1)
      with scopes.arg_scope([ops.conv2d], batch_norm_params={'decay': 0.9}):
        net = ops.conv2d(images, 32, [3, 3], scope='Conv')
        net = ops.conv2d(net, 32, [3, 3], scope='Conv', reuse=True)
      self.assertEquals(len(variables.get_variables()), 4)
      self.assertEquals(len(variables.get_variables('Conv/BatchNorm')), 3)
      self.assertEquals(len(variables.get_variables('Conv_1/BatchNorm')), 0) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:12,代码来源:ops_test.py

示例11: testReuseFCWithWD

# 需要导入模块: from inception.slim import variables [as 别名]
# 或者: from inception.slim.variables import get_variables [as 别名]
def testReuseFCWithWD(self):
    height, width = 3, 3
    with self.test_session():
      inputs = tf.random_uniform((5, height * width * 3), seed=1)
      ops.fc(inputs, 32, weight_decay=0.01, scope='fc')
      self.assertEquals(len(variables.get_variables()), 2)
      self.assertEquals(
          len(tf.get_collection(tf.GraphKeys.REGULARIZATION_LOSSES)), 1)
      ops.fc(inputs, 32, weight_decay=0.01, scope='fc', reuse=True)
      self.assertEquals(len(variables.get_variables()), 2)
      self.assertEquals(
          len(tf.get_collection(tf.GraphKeys.REGULARIZATION_LOSSES)), 1) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:14,代码来源:ops_test.py

示例12: testFCWithBatchNorm

# 需要导入模块: from inception.slim import variables [as 别名]
# 或者: from inception.slim.variables import get_variables [as 别名]
def testFCWithBatchNorm(self):
    height, width = 3, 3
    with self.test_session():
      images = tf.random_uniform((5, height * width * 3), seed=1)
      with scopes.arg_scope([ops.fc], batch_norm_params={}):
        net = ops.fc(images, 27)
        net = ops.fc(net, 27)
      self.assertEquals(len(variables.get_variables()), 8)
      self.assertEquals(len(variables.get_variables('FC/BatchNorm')), 3)
      self.assertEquals(len(variables.get_variables('FC_1/BatchNorm')), 3) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:12,代码来源:ops_test.py

示例13: testReuseFCWithBatchNorm

# 需要导入模块: from inception.slim import variables [as 别名]
# 或者: from inception.slim.variables import get_variables [as 别名]
def testReuseFCWithBatchNorm(self):
    height, width = 3, 3
    with self.test_session():
      images = tf.random_uniform((5, height * width * 3), seed=1)
      with scopes.arg_scope([ops.fc], batch_norm_params={'decay': 0.9}):
        net = ops.fc(images, 27, scope='fc1')
        net = ops.fc(net, 27, scope='fc1', reuse=True)
      self.assertEquals(len(variables.get_variables()), 4)
      self.assertEquals(len(variables.get_variables('fc1/BatchNorm')), 3) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:11,代码来源:ops_test.py

示例14: testEvalMovingVars

# 需要导入模块: from inception.slim import variables [as 别名]
# 或者: from inception.slim.variables import get_variables [as 别名]
def testEvalMovingVars(self):
    height, width = 3, 3
    with self.test_session() as sess:
      image_shape = (10, height, width, 3)
      image_values = np.random.rand(*image_shape)
      expected_mean = np.mean(image_values, axis=(0, 1, 2))
      expected_var = np.var(image_values, axis=(0, 1, 2))
      images = tf.constant(image_values, shape=image_shape, dtype=tf.float32)
      output = ops.batch_norm(images, decay=0.1, is_training=False)
      update_ops = tf.get_collection(ops.UPDATE_OPS_COLLECTION)
      with tf.control_dependencies(update_ops):
        output = tf.identity(output)
      # Initialize all variables
      sess.run(tf.global_variables_initializer())
      moving_mean = variables.get_variables('BatchNorm/moving_mean')[0]
      moving_variance = variables.get_variables('BatchNorm/moving_variance')[0]
      mean, variance = sess.run([moving_mean, moving_variance])
      # After initialization moving_mean == 0 and moving_variance == 1.
      self.assertAllClose(mean, [0] * 3)
      self.assertAllClose(variance, [1] * 3)
      # Simulate assigment from saver restore.
      init_assigns = [tf.assign(moving_mean, expected_mean),
                      tf.assign(moving_variance, expected_var)]
      sess.run(init_assigns)
      for _ in range(10):
        sess.run([output], {images: np.random.rand(*image_shape)})
      mean = moving_mean.eval()
      variance = moving_variance.eval()
      # Although we feed different images, the moving_mean and moving_variance
      # shouldn't change.
      self.assertAllClose(mean, expected_mean)
      self.assertAllClose(variance, expected_var) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:34,代码来源:ops_test.py


注:本文中的inception.slim.variables.get_variables方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。