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


Python resnet_v1.resnet_v1方法代码示例

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


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

示例1: _resnet_small

# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1 [as 别名]
def _resnet_small(self,
                    inputs,
                    num_classes=None,
                    global_pool=True,
                    output_stride=None,
                    include_root_block=True,
                    reuse=None,
                    scope='resnet_v1_small'):
    """A shallow and thin ResNet v1 for faster tests."""
    bottleneck = resnet_v1.bottleneck
    blocks = [
        resnet_utils.Block('block1', bottleneck, [(4, 1, 1)] * 2 + [(4, 1, 2)]),
        resnet_utils.Block('block2', bottleneck, [(8, 2, 1)] * 2 + [(8, 2, 2)]),
        resnet_utils.Block('block3', bottleneck,
                           [(16, 4, 1)] * 2 + [(16, 4, 2)]),
        resnet_utils.Block('block4', bottleneck, [(32, 8, 1)] * 2)
    ]
    return resnet_v1.resnet_v1(inputs, blocks, num_classes, global_pool,
                               output_stride, include_root_block, reuse, scope) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:21,代码来源:resnet_v1_test.py

示例2: _head_to_tail

# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1 [as 别名]
def _head_to_tail(self, pool5, is_training, reuse=None):
        with slim.arg_scope(resnet_arg_scope(is_training=is_training)):
            fc7_bef_pool, _ = resnet_v1.resnet_v1(pool5,
                                                  self._blocks[-1:],
                                                  global_pool=False,
                                                  include_root_block=False,
                                                  reuse=reuse,
                                                  scope=self._resnet_scope)
            # average pooling done by reduce_mean
            fc7 = tf.reduce_mean(fc7_bef_pool, axis=[1, 2])

        if cfg.DEBUG_ALL:
            self._for_debug['fc7'] = fc7
            self._for_debug['fc7_before_pool'] = fc7_bef_pool

        return fc7 
开发者ID:InnerPeace-Wu,项目名称:densecap-tensorflow,代码行数:18,代码来源:resnet_v1.py

示例3: res5

# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1 [as 别名]
def res5(self, pool5_H, pool5_O, sp, is_training, name):
        with slim.arg_scope(resnet_arg_scope(is_training=is_training)):

            fc7_H, _ = resnet_v1.resnet_v1(pool5_H,
                                           self.blocks[-2:-1],
                                           global_pool=False,
                                           include_root_block=False,
                                           reuse=False,
                                           scope=self.scope)

            fc7_H = tf.reduce_mean(fc7_H, axis=[1, 2])


            fc7_O, _ = resnet_v1.resnet_v1(pool5_O,
                                       self.blocks[-1:],
                                       global_pool=False,
                                       include_root_block=False,
                                       reuse=False,
                                       scope=self.scope)

            fc7_O = tf.reduce_mean(fc7_O, axis=[1, 2])
        
        return fc7_H, fc7_O 
开发者ID:vt-vl-lab,项目名称:iCAN,代码行数:25,代码来源:iCAN_ResNet50_VCOCO_Early.py

示例4: image_to_head

# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1 [as 别名]
def image_to_head(self, is_training):
        with slim.arg_scope(resnet_arg_scope(is_training=False)):
            net    = self.build_base()
            net, _ = resnet_v1.resnet_v1(net,
                                         self.blocks[0:cfg.RESNET.FIXED_BLOCKS], 
                                         global_pool=False,
                                         include_root_block=False,
                                         scope=self.scope)
        with slim.arg_scope(resnet_arg_scope(is_training=is_training)):
            head, _ = resnet_v1.resnet_v1(net,
                                          self.blocks[cfg.RESNET.FIXED_BLOCKS:-2], 
                                          global_pool=False,
                                          include_root_block=False,
                                          scope=self.scope)
        return head

    # spatial configuration, conv-pool-conv-pool-flatten 
开发者ID:DirtyHarryLYL,项目名称:Transferable-Interactiveness-Network,代码行数:19,代码来源:TIN_HICO.py

示例5: res5

# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1 [as 别名]
def res5(self, pool5_H, pool5_O, sp, is_training, name):
        with slim.arg_scope(resnet_arg_scope(is_training=is_training)):

            fc7_H, _ = resnet_v1.resnet_v1(pool5_H, # H input, one block
                                           self.blocks[-2:-1],
                                           global_pool=False,
                                           include_root_block=False,
                                           reuse=False,
                                           scope=self.scope)

            fc7_H = tf.reduce_mean(fc7_H, axis=[1, 2])


            fc7_O, _ = resnet_v1.resnet_v1(pool5_O, # O input, one block
                                       self.blocks[-1:],
                                       global_pool=False,
                                       include_root_block=False,
                                       reuse=False,
                                       scope=self.scope)

            fc7_O = tf.reduce_mean(fc7_O, axis=[1, 2])
        
        return fc7_H, fc7_O 
开发者ID:DirtyHarryLYL,项目名称:Transferable-Interactiveness-Network,代码行数:25,代码来源:TIN_HICO.py

示例6: testEndPointsV1

# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1 [as 别名]
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 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:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:35,代码来源:resnet_v1_test.py

示例7: testAtrousValuesBottleneck

# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1 [as 别名]
def testAtrousValuesBottleneck(self):
    self._atrousValues(resnet_v1.bottleneck) 
开发者ID:abhisuri97,项目名称:auto-alt-text-lambda-api,代码行数:4,代码来源:resnet_v1_test.py

示例8: _image_to_head

# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1 [as 别名]
def _image_to_head(self, is_training, reuse=None):
        assert (0 <= cfg.RESNET.FIXED_BLOCKS <= 3)
        # Now the base is always fixed during training
        with slim.arg_scope(resnet_arg_scope(is_training=False)):
            net_conv = self._build_base()

        end_points = {}
        if cfg.RESNET.FIXED_BLOCKS > 0:
            with slim.arg_scope(resnet_arg_scope(is_training=False)):
                net_conv, end_point = resnet_v1.resnet_v1(net_conv,
                                                  self._blocks[0:cfg.RESNET.FIXED_BLOCKS],
                                                  global_pool=False,
                                                  include_root_block=False,
                                                  reuse=reuse,
                                                  scope=self._scope)
        end_points.update(end_point)
        if cfg.RESNET.FIXED_BLOCKS < 3:
            with slim.arg_scope(resnet_arg_scope(is_training=is_training)):
                net_conv, end_points = resnet_v1.resnet_v1(net_conv,
                                                  self._blocks[cfg.RESNET.FIXED_BLOCKS:],
                                                  global_pool=False,
                                                  include_root_block=False,
                                                  reuse=reuse,
                                                  scope=self._scope)
        end_points.update(end_point)
        self.end_points['block1'] = end_points[self._scope + '/' + 'block1']
        self.end_points['block2'] = end_points[self._scope + '/' + 'block2']
        self.end_points['block3'] = end_points[self._scope + '/' + 'block3']
        self.end_points['block4'] = end_points[self._scope + '/' + 'block4']
        self._act_summaries.append(net_conv)
        self._layers['head'] = net_conv

        return net_conv 
开发者ID:wanjinchang,项目名称:SSH-TensorFlow,代码行数:35,代码来源:resnet_v1.py

示例9: _head_to_tail

# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1 [as 别名]
def _head_to_tail(self, pool5, is_training, reuse=None):
        with slim.arg_scope(resnet_arg_scope(is_training=is_training)):
            fc7, _ = resnet_v1.resnet_v1(pool5,
                                         self._blocks[-1:],
                                         global_pool=False,
                                         include_root_block=False,
                                         reuse=reuse,
                                         scope=self._scope)
            # average pooling done by reduce_mean
            fc7 = tf.reduce_mean(fc7, axis=[1, 2])
        return fc7 
开发者ID:wanjinchang,项目名称:SSH-TensorFlow,代码行数:13,代码来源:resnet_v1.py

示例10: _image_to_head

# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1 [as 别名]
def _image_to_head(self, is_training, reuse=None):
        assert (0 <= cfg.RESNET.FIXED_BLOCKS <= 3)
        # Now the base is always fixed during training
        with slim.arg_scope(resnet_arg_scope(is_training=False)):
            net_conv = self._build_base()
        if cfg.RESNET.FIXED_BLOCKS > 0:
            with slim.arg_scope(resnet_arg_scope(is_training=False)):
                net_conv, _ = resnet_v1.resnet_v1(net_conv,
                                                  self._blocks[0:cfg.RESNET.FIXED_BLOCKS],
                                                  global_pool=False,
                                                  include_root_block=False,
                                                  reuse=reuse,
                                                  scope=self._scope)
        if cfg.RESNET.FIXED_BLOCKS < 3:
            with slim.arg_scope(resnet_arg_scope(is_training=is_training)):
                net_conv, _ = resnet_v1.resnet_v1(net_conv,
                                                  self._blocks[cfg.RESNET.FIXED_BLOCKS:-1],
                                                  global_pool=False,
                                                  include_root_block=False,
                                                  reuse=reuse,
                                                  scope=self._scope)

        self._act_summaries.append(net_conv)
        self._layers['head'] = net_conv

        return net_conv 
开发者ID:Sanster,项目名称:tf_ctpn,代码行数:28,代码来源:resnet_v1.py

示例11: _image_to_head

# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1 [as 别名]
def _image_to_head(self, is_training, reuse=None):
        assert (0 <= cfg.RESNET.FIXED_BLOCKS <= 3)
        # Now the base is always fixed during training
        with slim.arg_scope(resnet_arg_scope(is_training=False)):
            net_conv = self._build_base()

        print("Fixing %s blocks." % cfg.RESNET.FIXED_BLOCKS)
        if cfg.RESNET.FIXED_BLOCKS > 0:
            with slim.arg_scope(resnet_arg_scope(is_training=False)):
                net_conv, _ = resnet_v1.resnet_v1(net_conv,
                                                  self._blocks[0:cfg.RESNET.FIXED_BLOCKS],
                                                  global_pool=False,
                                                  include_root_block=False,
                                                  reuse=reuse,
                                                  scope=self._resnet_scope)
        if cfg.RESNET.FIXED_BLOCKS < 3:
            with slim.arg_scope(resnet_arg_scope(is_training=is_training)):
                net_conv, _ = resnet_v1.resnet_v1(net_conv,
                                                  self._blocks[cfg.RESNET.FIXED_BLOCKS:-1],
                                                  global_pool=False,
                                                  include_root_block=False,
                                                  reuse=reuse,
                                                  scope=self._resnet_scope)

        self._act_summaries.append(net_conv)
        self._layers['head'] = net_conv

        if cfg.DEBUG_ALL:
            self._for_debug['head'] = net_conv

        return net_conv 
开发者ID:InnerPeace-Wu,项目名称:densecap-tensorflow,代码行数:33,代码来源:resnet_v1.py

示例12: _image_to_head

# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1 [as 别名]
def _image_to_head(self, is_training, reuse=None):
    assert (0 <= cfg.RESNET.FIXED_BLOCKS <= 3)
    # Now the base is always fixed during training
    with slim.arg_scope(resnet_arg_scope(is_training=False)):
      net_conv = self._build_base()
    if cfg.RESNET.FIXED_BLOCKS > 0:
      with slim.arg_scope(resnet_arg_scope(is_training=False)):
        net_conv, _ = resnet_v1.resnet_v1(net_conv,
                                           self._blocks[0:cfg.RESNET.FIXED_BLOCKS],
                                           global_pool=False,
                                           include_root_block=False,
                                           reuse=reuse,
                                           scope=self._scope)
    if cfg.RESNET.FIXED_BLOCKS < 3:
      with slim.arg_scope(resnet_arg_scope(is_training=is_training)):
        net_conv, _ = resnet_v1.resnet_v1(net_conv,
                                           self._blocks[cfg.RESNET.FIXED_BLOCKS:-1],
                                           global_pool=False,
                                           include_root_block=False,
                                           reuse=reuse,
                                           scope=self._scope)

    self._act_summaries.append(net_conv)
    self._layers['head'] = net_conv

    return net_conv 
开发者ID:endernewton,项目名称:tf-faster-rcnn,代码行数:28,代码来源:resnet_v1.py

示例13: _head_to_tail

# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1 [as 别名]
def _head_to_tail(self, pool5, is_training, reuse=None):
    with slim.arg_scope(resnet_arg_scope(is_training=is_training)):
      fc7, _ = resnet_v1.resnet_v1(pool5,
                                   self._blocks[-1:],
                                   global_pool=False,
                                   include_root_block=False,
                                   reuse=reuse,
                                   scope=self._scope)
      # average pooling done by reduce_mean
      fc7 = tf.reduce_mean(fc7, axis=[1, 2])
    return fc7 
开发者ID:endernewton,项目名称:tf-faster-rcnn,代码行数:13,代码来源:resnet_v1.py

示例14: resnet_arg_scope

# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1 [as 别名]
def resnet_arg_scope(is_training=True,
                     weight_decay=cfg.TRAIN.WEIGHT_DECAY,
                     batch_norm_decay=0.997,
                     batch_norm_epsilon=1e-5,
                     batch_norm_scale=True):
  batch_norm_params = {
    # NOTE 'is_training' here does not work because inside resnet it gets reset:
    # https://github.com/tensorflow/models/blob/master/slim/nets/resnet_v1.py#L187
    'is_training': False,
    'decay': batch_norm_decay,
    'epsilon': batch_norm_epsilon,
    'scale': batch_norm_scale,
    'trainable': cfg.RESNET.BN_TRAIN,
    'updates_collections': ops.GraphKeys.UPDATE_OPS
  }

  with arg_scope(
      [slim.conv2d],
      weights_regularizer=regularizers.l2_regularizer(weight_decay),
      weights_initializer=initializers.variance_scaling_initializer(),
      trainable=is_training,
      activation_fn=nn_ops.relu,
      normalizer_fn=layers.batch_norm,
      normalizer_params=batch_norm_params):
    with arg_scope([layers.batch_norm], **batch_norm_params) as arg_sc:
      return arg_sc 
开发者ID:dBeker,项目名称:Faster-RCNN-TensorFlow-Python3,代码行数:28,代码来源:resnet_v1.py

示例15: _decide_blocks

# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1 [as 别名]
def _decide_blocks(self):
    # choose different blocks for different number of layers
    if self._num_layers == 50:
      if tf.__version__ == '1.1.0':
        self._blocks     = [resnet_utils.Block('block1', resnet_v1.bottleneck,[(256,   64, 1)] * 2 + [(256,   64, 2)]),
                               resnet_utils.Block('block2', resnet_v1.bottleneck,[(512,  128, 1)] * 3 + [(512,  128, 2)]),
                               resnet_utils.Block('block3', resnet_v1.bottleneck,[(1024, 256, 1)] * 5 + [(1024, 256, 1)]),
                               resnet_utils.Block('block4', resnet_v1.bottleneck,[(2048, 512, 1)] * 3)]
      else:
        from tensorflow.contrib.slim.python.slim.nets.resnet_v1 import resnet_v1_block
        self._blocks = [resnet_v1_block('block1', base_depth=64, num_units=3, stride=2),
                       resnet_v1_block('block2', base_depth=128, num_units=4, stride=2),
                       resnet_v1_block('block3', base_depth=256, num_units=6, stride=1),
                       resnet_v1_block('block4', base_depth=512, num_units=3, stride=1)]

    elif self._num_layers == 101:
      self._blocks = [resnet_v1_block('block1', base_depth=64, num_units=3, stride=2),
                      resnet_v1_block('block2', base_depth=128, num_units=4, stride=2),
                      # use stride 1 for the last conv4 layer
                      resnet_v1_block('block3', base_depth=256, num_units=23, stride=1),
                      resnet_v1_block('block4', base_depth=512, num_units=3, stride=1)]

    elif self._num_layers == 152:
      self._blocks = [resnet_v1_block('block1', base_depth=64, num_units=3, stride=2),
                      resnet_v1_block('block2', base_depth=128, num_units=8, stride=2),
                      # use stride 1 for the last conv4 layer
                      resnet_v1_block('block3', base_depth=256, num_units=36, stride=1),
                      resnet_v1_block('block4', base_depth=512, num_units=3, stride=1)]

    else:
      # other numbers are not supported
      raise NotImplementedError 
开发者ID:vt-vl-lab,项目名称:iCAN,代码行数:34,代码来源:resnet_v1.py


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