當前位置: 首頁>>代碼示例>>Python>>正文


Python resnet_utils.resnet_arg_scope方法代碼示例

本文整理匯總了Python中tensorflow.contrib.slim.nets.resnet_utils.resnet_arg_scope方法的典型用法代碼示例。如果您正苦於以下問題:Python resnet_utils.resnet_arg_scope方法的具體用法?Python resnet_utils.resnet_arg_scope怎麽用?Python resnet_utils.resnet_arg_scope使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在tensorflow.contrib.slim.nets.resnet_utils的用法示例。


在下文中一共展示了resnet_utils.resnet_arg_scope方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testEndPointsV2

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_utils [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_utils import resnet_arg_scope [as 別名]
def testEndPointsV2(self):
    """Test the end points of a tiny v2 bottleneck network."""
    bottleneck = resnet_v2.bottleneck
    blocks = [resnet_utils.Block('block1', bottleneck, [(4, 1, 1), (4, 1, 2)]),
              resnet_utils.Block('block2', bottleneck, [(8, 2, 1), (8, 2, 1)])]
    inputs = create_test_input(2, 32, 16, 3)
    with slim.arg_scope(resnet_utils.resnet_arg_scope()):
      _, end_points = self._resnet_plain(inputs, blocks, scope='tiny')
    expected = [
        'tiny/block1/unit_1/bottleneck_v2/shortcut',
        'tiny/block1/unit_1/bottleneck_v2/conv1',
        'tiny/block1/unit_1/bottleneck_v2/conv2',
        'tiny/block1/unit_1/bottleneck_v2/conv3',
        'tiny/block1/unit_2/bottleneck_v2/conv1',
        'tiny/block1/unit_2/bottleneck_v2/conv2',
        'tiny/block1/unit_2/bottleneck_v2/conv3',
        'tiny/block2/unit_1/bottleneck_v2/shortcut',
        'tiny/block2/unit_1/bottleneck_v2/conv1',
        'tiny/block2/unit_1/bottleneck_v2/conv2',
        'tiny/block2/unit_1/bottleneck_v2/conv3',
        'tiny/block2/unit_2/bottleneck_v2/conv1',
        'tiny/block2/unit_2/bottleneck_v2/conv2',
        'tiny/block2/unit_2/bottleneck_v2/conv3']
    self.assertItemsEqual(expected, end_points) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:26,代碼來源:resnet_v2_test.py

示例2: testAtrousFullyConvolutionalEndpointShapes

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_utils [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_utils import resnet_arg_scope [as 別名]
def testAtrousFullyConvolutionalEndpointShapes(self):
    global_pool = False
    num_classes = 10
    output_stride = 8
    inputs = create_test_input(2, 321, 321, 3)
    with slim.arg_scope(resnet_utils.resnet_arg_scope()):
      _, end_points = self._resnet_small(inputs,
                                         num_classes,
                                         global_pool,
                                         output_stride=output_stride,
                                         scope='resnet')
      endpoint_to_shape = {
          'resnet/block1': [2, 41, 41, 4],
          'resnet/block2': [2, 41, 41, 8],
          'resnet/block3': [2, 41, 41, 16],
          'resnet/block4': [2, 41, 41, 32]}
      for endpoint in endpoint_to_shape:
        shape = endpoint_to_shape[endpoint]
        self.assertListEqual(end_points[endpoint].get_shape().as_list(), shape) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:21,代碼來源:resnet_v2_test.py

示例3: testAtrousFullyConvolutionalValues

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_utils [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_utils import resnet_arg_scope [as 別名]
def testAtrousFullyConvolutionalValues(self):
    """Verify dense feature extraction with atrous convolution."""
    nominal_stride = 32
    for output_stride in [4, 8, 16, 32, None]:
      with slim.arg_scope(resnet_utils.resnet_arg_scope(is_training=False)):
        with tf.Graph().as_default():
          with self.test_session() as sess:
            tf.set_random_seed(0)
            inputs = create_test_input(2, 81, 81, 3)
            # Dense feature extraction followed by subsampling.
            output, _ = self._resnet_small(inputs, None, global_pool=False,
                                           output_stride=output_stride)
            if output_stride is None:
              factor = 1
            else:
              factor = nominal_stride // output_stride
            output = resnet_utils.subsample(output, factor)
            # Make the two networks use the same weights.
            tf.get_variable_scope().reuse_variables()
            # Feature extraction at the nominal network rate.
            expected, _ = self._resnet_small(inputs, None, global_pool=False)
            sess.run(tf.global_variables_initializer())
            self.assertAllClose(output.eval(), expected.eval(),
                                atol=1e-4, rtol=1e-4) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:26,代碼來源:resnet_v2_test.py

示例4: testUnknownBatchSize

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_utils [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_utils import resnet_arg_scope [as 別名]
def testUnknownBatchSize(self):
    batch = 2
    height, width = 65, 65
    global_pool = True
    num_classes = 10
    inputs = create_test_input(None, height, width, 3)
    with slim.arg_scope(resnet_utils.resnet_arg_scope()):
      logits, _ = self._resnet_small(inputs, num_classes, global_pool,
                                     scope='resnet')
    self.assertTrue(logits.op.name.startswith('resnet/logits'))
    self.assertListEqual(logits.get_shape().as_list(),
                         [None, 1, 1, num_classes])
    images = create_test_input(batch, height, width, 3)
    with self.test_session() as sess:
      sess.run(tf.global_variables_initializer())
      output = sess.run(logits, {inputs: images.eval()})
      self.assertEqual(output.shape, (batch, 1, 1, num_classes)) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:19,代碼來源:resnet_v2_test.py

示例5: testAtrousFullyConvolutionalUnknownHeightWidth

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_utils [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_utils import resnet_arg_scope [as 別名]
def testAtrousFullyConvolutionalUnknownHeightWidth(self):
    batch = 2
    height, width = 65, 65
    global_pool = False
    output_stride = 8
    inputs = create_test_input(batch, None, None, 3)
    with slim.arg_scope(resnet_utils.resnet_arg_scope()):
      output, _ = self._resnet_small(inputs,
                                     None,
                                     global_pool,
                                     output_stride=output_stride)
    self.assertListEqual(output.get_shape().as_list(),
                         [batch, None, None, 32])
    images = create_test_input(batch, height, width, 3)
    with self.test_session() as sess:
      sess.run(tf.global_variables_initializer())
      output = sess.run(output, {inputs: images.eval()})
      self.assertEqual(output.shape, (batch, 9, 9, 32)) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:20,代碼來源:resnet_v2_test.py

示例6: testRootlessFullyConvolutionalEndpointShapes

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_utils [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_utils import resnet_arg_scope [as 別名]
def testRootlessFullyConvolutionalEndpointShapes(self):
    global_pool = False
    num_classes = 10
    inputs = create_test_input(2, 128, 128, 3)
    with slim.arg_scope(resnet_utils.resnet_arg_scope()):
      _, end_points = self._resnet_small(inputs, num_classes, global_pool,
                                         include_root_block=False,
                                         scope='resnet')
      endpoint_to_shape = {
          'resnet/block1': [2, 64, 64, 4],
          'resnet/block2': [2, 32, 32, 8],
          'resnet/block3': [2, 16, 16, 16],
          'resnet/block4': [2, 16, 16, 32]}
      for endpoint in endpoint_to_shape:
        shape = endpoint_to_shape[endpoint]
        self.assertListEqual(end_points[endpoint].get_shape().as_list(), shape) 
開發者ID:tobegit3hub,項目名稱:deep_image_model,代碼行數:18,代碼來源:resnet_v1_test.py

示例7: testClassificationEndPointsWithMultigrid

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_utils [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_utils import resnet_arg_scope [as 別名]
def testClassificationEndPointsWithMultigrid(self):
    global_pool = True
    num_classes = 10
    inputs = create_test_input(2, 224, 224, 3)
    multi_grid = [1, 2, 4]
    with slim.arg_scope(resnet_utils.resnet_arg_scope()):
      logits, end_points = self._resnet_small(inputs,
                                              num_classes,
                                              global_pool=global_pool,
                                              multi_grid=multi_grid,
                                              scope='resnet')

    self.assertTrue(logits.op.name.startswith('resnet/logits'))
    self.assertListEqual(logits.get_shape().as_list(), [2, 1, 1, num_classes])
    self.assertTrue('predictions' in end_points)
    self.assertListEqual(end_points['predictions'].get_shape().as_list(),
                         [2, 1, 1, num_classes]) 
開發者ID:IBM,項目名稱:MAX-Image-Segmenter,代碼行數:19,代碼來源:resnet_v1_beta_test.py

示例8: testClassificationShapes

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_utils [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_utils import resnet_arg_scope [as 別名]
def testClassificationShapes(self):
    global_pool = True
    num_classes = 10
    inputs = create_test_input(2, 224, 224, 3)
    with slim.arg_scope(resnet_utils.resnet_arg_scope()):
      _, end_points = self._resnet_small(inputs,
                                         num_classes,
                                         global_pool=global_pool,
                                         scope='resnet')
      endpoint_to_shape = {
          'resnet/conv1_1': [2, 112, 112, 64],
          'resnet/conv1_2': [2, 112, 112, 64],
          'resnet/conv1_3': [2, 112, 112, 128],
          'resnet/block1': [2, 28, 28, 4],
          'resnet/block2': [2, 14, 14, 8],
          'resnet/block3': [2, 7, 7, 16],
          'resnet/block4': [2, 7, 7, 32]}
      for endpoint, shape in endpoint_to_shape.iteritems():
        self.assertListEqual(end_points[endpoint].get_shape().as_list(), shape) 
開發者ID:IBM,項目名稱:MAX-Image-Segmenter,代碼行數:21,代碼來源:resnet_v1_beta_test.py

示例9: testFullyConvolutionalEndpointShapes

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_utils [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_utils import resnet_arg_scope [as 別名]
def testFullyConvolutionalEndpointShapes(self):
    global_pool = False
    num_classes = 10
    inputs = create_test_input(2, 321, 321, 3)
    with slim.arg_scope(resnet_utils.resnet_arg_scope()):
      _, end_points = self._resnet_small(inputs,
                                         num_classes,
                                         global_pool=global_pool,
                                         scope='resnet')
      endpoint_to_shape = {
          'resnet/conv1_1': [2, 161, 161, 64],
          'resnet/conv1_2': [2, 161, 161, 64],
          'resnet/conv1_3': [2, 161, 161, 128],
          'resnet/block1': [2, 41, 41, 4],
          'resnet/block2': [2, 21, 21, 8],
          'resnet/block3': [2, 11, 11, 16],
          'resnet/block4': [2, 11, 11, 32]}
      for endpoint, shape in endpoint_to_shape.iteritems():
        self.assertListEqual(end_points[endpoint].get_shape().as_list(), shape) 
開發者ID:IBM,項目名稱:MAX-Image-Segmenter,代碼行數:21,代碼來源:resnet_v1_beta_test.py

示例10: testAtrousFullyConvolutionalEndpointShapes

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_utils [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_utils import resnet_arg_scope [as 別名]
def testAtrousFullyConvolutionalEndpointShapes(self):
    global_pool = False
    num_classes = 10
    output_stride = 8
    inputs = create_test_input(2, 321, 321, 3)
    with slim.arg_scope(resnet_utils.resnet_arg_scope()):
      _, end_points = self._resnet_small(inputs,
                                         num_classes,
                                         global_pool=global_pool,
                                         output_stride=output_stride,
                                         scope='resnet')
      endpoint_to_shape = {
          'resnet/conv1_1': [2, 161, 161, 64],
          'resnet/conv1_2': [2, 161, 161, 64],
          'resnet/conv1_3': [2, 161, 161, 128],
          'resnet/block1': [2, 41, 41, 4],
          'resnet/block2': [2, 41, 41, 8],
          'resnet/block3': [2, 41, 41, 16],
          'resnet/block4': [2, 41, 41, 32]}
      for endpoint, shape in endpoint_to_shape.iteritems():
        self.assertListEqual(end_points[endpoint].get_shape().as_list(), shape) 
開發者ID:IBM,項目名稱:MAX-Image-Segmenter,代碼行數:23,代碼來源:resnet_v1_beta_test.py

示例11: testUnknownBatchSize

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_utils [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_utils import resnet_arg_scope [as 別名]
def testUnknownBatchSize(self):
    batch = 2
    height, width = 65, 65
    global_pool = True
    num_classes = 10
    inputs = create_test_input(None, height, width, 3)
    with slim.arg_scope(resnet_utils.resnet_arg_scope()):
      logits, _ = self._resnet_small(inputs,
                                     num_classes,
                                     global_pool=global_pool,
                                     scope='resnet')
    self.assertTrue(logits.op.name.startswith('resnet/logits'))
    self.assertListEqual(logits.get_shape().as_list(),
                         [None, 1, 1, num_classes])
    images = create_test_input(batch, height, width, 3)
    with self.test_session() as sess:
      sess.run(tf.global_variables_initializer())
      output = sess.run(logits, {inputs: images.eval()})
      self.assertEquals(output.shape, (batch, 1, 1, num_classes)) 
開發者ID:IBM,項目名稱:MAX-Image-Segmenter,代碼行數:21,代碼來源:resnet_v1_beta_test.py

示例12: testFullyConvolutionalUnknownHeightWidth

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_utils [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_utils import resnet_arg_scope [as 別名]
def testFullyConvolutionalUnknownHeightWidth(self):
    batch = 2
    height, width = 65, 65
    global_pool = False
    inputs = create_test_input(batch, None, None, 3)
    with slim.arg_scope(resnet_utils.resnet_arg_scope()):
      output, _ = self._resnet_small(inputs,
                                     None,
                                     global_pool=global_pool)
    self.assertListEqual(output.get_shape().as_list(),
                         [batch, None, None, 32])
    images = create_test_input(batch, height, width, 3)
    with self.test_session() as sess:
      sess.run(tf.global_variables_initializer())
      output = sess.run(output, {inputs: images.eval()})
      self.assertEquals(output.shape, (batch, 3, 3, 32)) 
開發者ID:IBM,項目名稱:MAX-Image-Segmenter,代碼行數:18,代碼來源:resnet_v1_beta_test.py

示例13: testAtrousFullyConvolutionalUnknownHeightWidth

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_utils [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_utils import resnet_arg_scope [as 別名]
def testAtrousFullyConvolutionalUnknownHeightWidth(self):
    batch = 2
    height, width = 65, 65
    global_pool = False
    output_stride = 8
    inputs = create_test_input(batch, None, None, 3)
    with slim.arg_scope(resnet_utils.resnet_arg_scope()):
      output, _ = self._resnet_small(inputs,
                                     None,
                                     global_pool=global_pool,
                                     output_stride=output_stride)
    self.assertListEqual(output.get_shape().as_list(),
                         [batch, None, None, 32])
    images = create_test_input(batch, height, width, 3)
    with self.test_session() as sess:
      sess.run(tf.global_variables_initializer())
      output = sess.run(output, {inputs: images.eval()})
      self.assertEquals(output.shape, (batch, 9, 9, 32)) 
開發者ID:IBM,項目名稱:MAX-Image-Segmenter,代碼行數:20,代碼來源:resnet_v1_beta_test.py

示例14: testClassificationEndPointsWithLiteBottleneck

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_utils [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_utils import resnet_arg_scope [as 別名]
def testClassificationEndPointsWithLiteBottleneck(self):
    global_pool = True
    num_classes = 10
    inputs = create_test_input(2, 224, 224, 3)
    with slim.arg_scope(resnet_utils.resnet_arg_scope()):
      logits, end_points = self._resnet_small_lite_bottleneck(
          inputs,
          num_classes,
          global_pool=global_pool,
          scope='resnet')

    self.assertTrue(logits.op.name.startswith('resnet/logits'))
    self.assertListEqual(logits.get_shape().as_list(), [2, 1, 1, num_classes])
    self.assertIn('predictions', end_points)
    self.assertListEqual(end_points['predictions'].get_shape().as_list(),
                         [2, 1, 1, num_classes]) 
開發者ID:tensorflow,項目名稱:models,代碼行數:18,代碼來源:resnet_v1_beta_test.py

示例15: testClassificationEndPointsWithMultigridAndLiteBottleneck

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_utils [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_utils import resnet_arg_scope [as 別名]
def testClassificationEndPointsWithMultigridAndLiteBottleneck(self):
    global_pool = True
    num_classes = 10
    inputs = create_test_input(2, 224, 224, 3)
    multi_grid = [1, 2]
    with slim.arg_scope(resnet_utils.resnet_arg_scope()):
      logits, end_points = self._resnet_small_lite_bottleneck(
          inputs,
          num_classes,
          global_pool=global_pool,
          multi_grid=multi_grid,
          scope='resnet')

    self.assertTrue(logits.op.name.startswith('resnet/logits'))
    self.assertListEqual(logits.get_shape().as_list(), [2, 1, 1, num_classes])
    self.assertIn('predictions', end_points)
    self.assertListEqual(end_points['predictions'].get_shape().as_list(),
                         [2, 1, 1, num_classes]) 
開發者ID:tensorflow,項目名稱:models,代碼行數:20,代碼來源:resnet_v1_beta_test.py


注:本文中的tensorflow.contrib.slim.nets.resnet_utils.resnet_arg_scope方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。