• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python resnet_utils.resnet_arg_scope函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中tensorflow.contrib.slim.nets.resnet_utils.resnet_arg_scope函数的典型用法代码示例。如果您正苦于以下问题:Python resnet_arg_scope函数的具体用法?Python resnet_arg_scope怎么用?Python resnet_arg_scope使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: testEndPointsV2

 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:apollos,项目名称:tensorflow,代码行数:27,代码来源:resnet_v2_test.py


示例2: testAtrousFullyConvolutionalValues

 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()):
       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,
                                          is_training=False,
                                          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,
                                            is_training=False,
                                            global_pool=False)
           sess.run(tf.global_variables_initializer())
           self.assertAllClose(output.eval(), expected.eval(),
                               atol=1e-4, rtol=1e-4)
开发者ID:IoannisKansizoglou,项目名称:models,代码行数:30,代码来源:resnet_v1_beta_test.py


示例3: testEndPointsV1

 def testEndPointsV1(self):
   """Test the end points of a tiny v1 bottleneck network."""
   bottleneck = resnet_v1.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_v1/shortcut',
       'tiny/block1/unit_1/bottleneck_v1/shortcut/BatchNorm',
       'tiny/block1/unit_1/bottleneck_v1/conv1',
       'tiny/block1/unit_1/bottleneck_v1/conv2',
       'tiny/block1/unit_1/bottleneck_v1/conv3',
       'tiny/block1/unit_1/bottleneck_v1/conv3/BatchNorm',
       'tiny/block1/unit_2/bottleneck_v1/conv1',
       'tiny/block1/unit_2/bottleneck_v1/conv2',
       'tiny/block1/unit_2/bottleneck_v1/conv3',
       'tiny/block1/unit_2/bottleneck_v1/conv3/BatchNorm',
       'tiny/block2/unit_1/bottleneck_v1/shortcut',
       'tiny/block2/unit_1/bottleneck_v1/shortcut/BatchNorm',
       'tiny/block2/unit_1/bottleneck_v1/conv1',
       'tiny/block2/unit_1/bottleneck_v1/conv2',
       'tiny/block2/unit_1/bottleneck_v1/conv3',
       'tiny/block2/unit_1/bottleneck_v1/conv3/BatchNorm',
       'tiny/block2/unit_2/bottleneck_v1/conv1',
       'tiny/block2/unit_2/bottleneck_v1/conv2',
       'tiny/block2/unit_2/bottleneck_v1/conv3',
       'tiny/block2/unit_2/bottleneck_v1/conv3/BatchNorm']
   self.assertItemsEqual(expected, end_points)
开发者ID:moolighty,项目名称:tensorflow,代码行数:30,代码来源:resnet_v1_test.py


示例4: testClassificationEndPoints

 def testClassificationEndPoints(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(inputs, num_classes, 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.assertTrue("predictions" in end_points)
     self.assertListEqual(end_points["predictions"].get_shape().as_list(), [2, 1, 1, num_classes])
开发者ID:apollos,项目名称:tensorflow,代码行数:10,代码来源:resnet_v2_test.py


示例5: testFullyConvolutionalUnknownHeightWidth

 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)
     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.initialize_all_variables())
         output = sess.run(output, {inputs: images.eval()})
         self.assertEqual(output.shape, (batch, 3, 3, 32))
开发者ID:apollos,项目名称:tensorflow,代码行数:13,代码来源:resnet_v2_test.py


示例6: testFullyConvolutionalEndpointShapes

 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,
                                        scope='resnet')
     endpoint_to_shape = {
         '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 in endpoint_to_shape:
       shape = endpoint_to_shape[endpoint]
       self.assertListEqual(end_points[endpoint].get_shape().as_list(), shape)
开发者ID:ComeOnGetMe,项目名称:tensorflow,代码行数:15,代码来源:resnet_v2_test.py


示例7: testClassificationShapes

 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,
                                        scope='resnet')
     endpoint_to_shape = {
         '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 in endpoint_to_shape:
       shape = endpoint_to_shape[endpoint]
       self.assertListEqual(end_points[endpoint].get_shape().as_list(), shape)
开发者ID:ComeOnGetMe,项目名称:tensorflow,代码行数:15,代码来源:resnet_v2_test.py


示例8: testUnknownBatchSize

 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.initialize_all_variables())
         output = sess.run(logits, {inputs: images.eval()})
         self.assertEqual(output.shape, (batch, 1, 1, num_classes))
开发者ID:apollos,项目名称:tensorflow,代码行数:15,代码来源:resnet_v2_test.py


示例9: testClassificationEndPointsWithMultigrid

  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:IoannisKansizoglou,项目名称:models,代码行数:17,代码来源:resnet_v1_beta_test.py


示例10: testRootlessFullyConvolutionalEndpointShapes

 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:apollos,项目名称:tensorflow,代码行数:17,代码来源:resnet_v2_test.py


示例11: testAtrousFullyConvolutionalEndpointShapes

 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:apollos,项目名称:tensorflow,代码行数:18,代码来源:resnet_v2_test.py


示例12: _atrousValues

  def _atrousValues(self, bottleneck):
    """Verify the values of dense feature extraction by atrous convolution.

    Make sure that dense feature extraction by stack_blocks_dense() followed by
    subsampling gives identical results to feature extraction at the nominal
    network output stride using the simple self._stack_blocks_nondense() above.

    Args:
      bottleneck: The bottleneck function.
    """
    blocks = [
        resnet_utils.Block('block1', bottleneck, [(4, 1, 1), (4, 1, 2)]),
        resnet_utils.Block('block2', bottleneck, [(8, 2, 1), (8, 2, 2)]),
        resnet_utils.Block('block3', bottleneck, [(16, 4, 1), (16, 4, 2)]),
        resnet_utils.Block('block4', bottleneck, [(32, 8, 1), (32, 8, 1)])
    ]
    nominal_stride = 8

    # Test both odd and even input dimensions.
    height = 30
    width = 31
    with slim.arg_scope(resnet_utils.resnet_arg_scope(is_training=False)):
      for output_stride in [1, 2, 4, 8, None]:
        with tf.Graph().as_default():
          with self.test_session() as sess:
            tf.set_random_seed(0)
            inputs = create_test_input(1, height, width, 3)
            # Dense feature extraction followed by subsampling.
            output = resnet_utils.stack_blocks_dense(inputs,
                                                     blocks,
                                                     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._stack_blocks_nondense(inputs, blocks)
            sess.run(tf.global_variables_initializer())
            output, expected = sess.run([output, expected])
            self.assertAllClose(output, expected, atol=1e-4, rtol=1e-4)
开发者ID:ComeOnGetMe,项目名称:tensorflow,代码行数:44,代码来源:resnet_v2_test.py


示例13: testAtrousFullyConvolutionalEndpointShapes

 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:IoannisKansizoglou,项目名称:models,代码行数:21,代码来源:resnet_v1_beta_test.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python learning.create_train_op函数代码示例发布时间:2022-05-27
下一篇:
Python slim.max_pool2d函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap