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


Python resnet_v1.resnet_v1_50方法代碼示例

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


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

示例1: setUp

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_v1 [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_v1 import resnet_v1_50 [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

示例2: video_model

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_v1 [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_v1 import resnet_v1_50 [as 別名]
def video_model(video_frames=None, audio_frames=None):
    """Creates the video model.
    
    Args:
        video_frames: A tensor that contains the video input.
        audio_frames: not needed (leave None).
    Returns:
        The video model.
    """

    with tf.variable_scope("video_model"):
        batch_size, seq_length, height, width, channels = video_frames.get_shape().as_list()

        video_input = tf.reshape(video_frames, (batch_size * seq_length, height, width, channels))
        video_input = tf.cast(video_input, tf.float32)

        features, end_points = resnet_v1.resnet_v1_50(video_input, None)
        features = tf.reshape(features, (batch_size, seq_length, int(features.get_shape()[3])))

    return features 
開發者ID:tzirakis,項目名稱:Multimodal-Emotion-Recognition,代碼行數:22,代碼來源:models.py

示例3: det_lesion_resnet

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_v1 [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_v1 import resnet_v1_50 [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

示例4: load_resnet_imagenet

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_v1 [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_v1 import resnet_v1_50 [as 別名]
def load_resnet_imagenet(ckpt_path):
    """Initialize the network parameters from the Resnet-50 pre-trained model provided by TF-SLIM
    Args:
    Path to the checkpoint
    Returns:
    Function that takes a session and initializes the network
    """
    reader = tf.train.NewCheckpointReader(ckpt_path)
    var_to_shape_map = reader.get_variable_to_shape_map()
    vars_corresp = dict()
    
    for v in var_to_shape_map:
        if "bottleneck_v1" in v or "conv1" in v:
            vars_corresp[v] = slim.get_model_variables(v.replace("resnet_v1_50", "det_lesion/resnet_v1_50"))[0]
    init_fn = slim.assign_from_checkpoint_fn(ckpt_path, vars_corresp)
    return init_fn 
開發者ID:imatge-upc,項目名稱:liverseg-2017-nipsws,代碼行數:18,代碼來源:det_lesion.py

示例5: test_resnet

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_v1 [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_v1 import resnet_v1_50 [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

示例6: build_graph

# 需要導入模塊: from tensorflow.contrib.slim.nets import resnet_v1 [as 別名]
# 或者: from tensorflow.contrib.slim.nets.resnet_v1 import resnet_v1_50 [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_v1_50方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。