當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。