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


Python resnet_v1.resnet_arg_scope方法代码示例

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


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

示例1: forward

# 需要导入模块: from tensorflow.contrib.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.nets.resnet_v1 import resnet_arg_scope [as 别名]
def forward(self, inputs, num_classes, data_format, is_training):
        sc = resnet_arg_scope(
            weight_decay=0.0001,
            data_format=data_format,
            batch_norm_decay=0.997,
            batch_norm_epsilon=1e-5,
            batch_norm_scale=True,
            activation_fn=tf.nn.relu,
            use_batch_norm=True,
            is_training=is_training)
        with slim.arg_scope(sc):
            logits, end_points = resnet_v1_50(
                inputs,
                num_classes=num_classes,
                is_training=is_training,
                global_pool=True,
                output_stride=None,
                reuse=None,
                scope=self.scope)
            return logits, end_points 
开发者ID:balancap,项目名称:tf-imagenet,代码行数:22,代码来源:resnet_v1.py

示例2: setUp

# 需要导入模块: from tensorflow.contrib.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.nets.resnet_v1 import resnet_arg_scope [as 别名]
def setUp(self):
        tf.reset_default_graph()

        self.nbclasses = 1000
        inputs = tf.placeholder(tf.float32, [1, 224, 224, 3])
        with slim.arg_scope(resnet_v1.resnet_arg_scope()):
            net, end_points = resnet_v1.resnet_v1_50(inputs, self.nbclasses, is_training=False)
        saver = tf.train.Saver(tf.global_variables())
        check_point = 'test/data/resnet_v1_50.ckpt'

        sess = tf.InteractiveSession()
        saver.restore(sess, check_point)

        conv_name = 'resnet_v1_50/block4/unit_3/bottleneck_v1/Relu'
        
        self.graph_origin = tf.get_default_graph().as_graph_def()
        self.insp = darkon.Gradcam(inputs, self.nbclasses, conv_name)
        self.sess = sess 
开发者ID:darkonhub,项目名称:darkon,代码行数:20,代码来源:test_gradcam_dangling.py

示例3: extract_features

# 需要导入模块: from tensorflow.contrib.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.nets.resnet_v1 import resnet_arg_scope [as 别名]
def extract_features(self, inputs):
        net_fun = net_funcs[self.cfg.net_type]

        mean = tf.constant(
            self.cfg.mean_pixel, dtype=tf.float32, shape=[1, 1, 1, 3], name="img_mean"
        )
        im_centered = inputs - mean

        # The next part of the code depends upon which tensorflow version you have.
        vers = tf.__version__
        vers = vers.split(
            "."
        )  # Updated based on https://github.com/AlexEMG/DeepLabCut/issues/44
        if int(vers[0]) == 1 and int(vers[1]) < 4:  # check if lower than version 1.4.
            with slim.arg_scope(resnet_v1.resnet_arg_scope(False)):
                net, end_points = net_fun(
                    im_centered, global_pool=False, output_stride=16
                )
        else:
            with slim.arg_scope(resnet_v1.resnet_arg_scope()):
                net, end_points = net_fun(
                    im_centered, global_pool=False, output_stride=16, is_training=False
                )

        return net, end_points 
开发者ID:DeepLabCut,项目名称:DeepLabCut,代码行数:27,代码来源:pose_netmulti.py

示例4: resnet_v1_101_c4

# 需要导入模块: from tensorflow.contrib.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.nets.resnet_v1 import resnet_arg_scope [as 别名]
def resnet_v1_101_c4(inputs, is_training, reuse=None, scope='resnet_v1_101'):
    """
    ResNet-101 model of [1]. See resnet_v1() for arg and return description.
    """
    with slim.arg_scope(resnet_arg_scope()):
        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 to extract 14 x 14 feature. The stride is applied
          # in the last unit of the block, followed by 1x1 convolution, so
          # changing the stride to 2 only makes the sampling denser.
          resnet_v1_block('block3', base_depth=256, num_units=23, stride=1),
        ]
        net, _ = resnet_v1(
            inputs, blocks, num_classes=None, is_training=is_training,
            global_pool=False, output_stride=None,
            include_root_block=True, spatial_squeeze=True,
            reuse=reuse, scope=scope)
    return net 
开发者ID:ronghanghu,项目名称:snmn,代码行数:21,代码来源:resnet_v1.py

示例5: resnet_v1_152_c5

# 需要导入模块: from tensorflow.contrib.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.nets.resnet_v1 import resnet_arg_scope [as 别名]
def resnet_v1_152_c5(inputs, is_training, reuse=None, scope='resnet_v1_152'):
    """
    ResNet-152 model of [1]. See resnet_v1() for arg and return description.
    """
    with slim.arg_scope(resnet_arg_scope()):
        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),
            resnet_v1_block('block3', base_depth=256, num_units=36, stride=2),
            resnet_v1_block('block4', base_depth=512, num_units=3, stride=1),
        ]
        net, _ = resnet_v1(
            inputs, blocks, num_classes=None, is_training=is_training,
            global_pool=False, output_stride=None,
            include_root_block=True, spatial_squeeze=True,
            reuse=reuse, scope=scope)
    return net 
开发者ID:ronghanghu,项目名称:snmn,代码行数:19,代码来源:resnet_v1.py

示例6: det_lesion_resnet

# 需要导入模块: from tensorflow.contrib.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.nets.resnet_v1 import resnet_arg_scope [as 别名]
def det_lesion_resnet(inputs, is_training_option=False, scope='det_lesion'):
    """Defines the network
    Args:
    inputs: Tensorflow placeholder that contains the input image
    scope: Scope name for the network
    Returns:
    net: Output Tensor of the network
    end_points: Dictionary with all Tensors of the network
    """

    with tf.variable_scope(scope, 'det_lesion', [inputs]) as sc:
        end_points_collection = sc.name + '_end_points'
        with slim.arg_scope(resnet_v1.resnet_arg_scope()):

            net, end_points = resnet_v1.resnet_v1_50(inputs, is_training=is_training_option)
            net = slim.flatten(net, scope='flatten5')
            net = slim.fully_connected(net, 1, activation_fn=tf.nn.sigmoid,
                                       weights_initializer=initializers.xavier_initializer(), scope='output')
            utils.collect_named_outputs(end_points_collection, 'det_lesion/output', net)

    end_points = slim.utils.convert_collection_to_dict(end_points_collection)
    return net, end_points 
开发者ID:imatge-upc,项目名称:liverseg-2017-nipsws,代码行数:24,代码来源:det_lesion.py

示例7: test_resnet

# 需要导入模块: from tensorflow.contrib.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.nets.resnet_v1 import resnet_arg_scope [as 别名]
def test_resnet(self):
        with slim.arg_scope(resnet_v1.resnet_arg_scope()):
            net, end_points = resnet_v1.resnet_v1_50(self.inputs, self.nbclasses, is_training=False)
        saver = tf.train.Saver(tf.global_variables())
        check_point = 'test/data/resnet_v1_50.ckpt'
        sess = tf.InteractiveSession()
        saver.restore(sess, check_point)

        self.sess = sess
        self.graph_origin = tf.get_default_graph()
        self.target_op_name = darkon.Gradcam.candidate_featuremap_op_names(sess, self.graph_origin)[-1]
        self.model_name = 'resnet'
        
        self.assertEqual('resnet_v1_50/block4/unit_3/bottleneck_v1/Relu', self.target_op_name) 
开发者ID:darkonhub,项目名称:darkon,代码行数:16,代码来源:test_gradcam.py

示例8: build_graph

# 需要导入模块: from tensorflow.contrib.slim.nets import resnet_v1 [as 别名]
# 或者: from tensorflow.contrib.slim.nets.resnet_v1 import resnet_arg_scope [as 别名]
def build_graph(self, orig_image):
        mean = tf.get_variable('resnet_v1_50/mean_rgb', shape=[3])
        with guided_relu():
            with slim.arg_scope(resnet_v1.resnet_arg_scope()):
                image = tf.expand_dims(orig_image - mean, 0)
                logits, _ = resnet_v1.resnet_v1_50(image, 1000, is_training=False)
            saliency_map(logits, orig_image, name="saliency") 
开发者ID:tensorpack,项目名称:tensorpack,代码行数:9,代码来源:saliency-maps.py


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