本文整理汇总了Python中tensorflow.contrib.slim.python.slim.nets.resnet_v2.resnet_v2_50方法的典型用法代码示例。如果您正苦于以下问题:Python resnet_v2.resnet_v2_50方法的具体用法?Python resnet_v2.resnet_v2_50怎么用?Python resnet_v2.resnet_v2_50使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tensorflow.contrib.slim.python.slim.nets.resnet_v2
的用法示例。
在下文中一共展示了resnet_v2.resnet_v2_50方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build_pretrained_graph
# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v2 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v2 import resnet_v2_50 [as 别名]
def build_pretrained_graph(
self, images, resnet_layer, checkpoint, is_training, reuse=False):
"""See baseclass."""
with slim.arg_scope(resnet_v2.resnet_arg_scope()):
_, endpoints = resnet_v2.resnet_v2_50(
images, is_training=is_training, reuse=reuse)
resnet_layer = 'resnet_v2_50/block%d' % resnet_layer
resnet_output = endpoints[resnet_layer]
resnet_variables = slim.get_variables_to_restore()
resnet_variables = [
i for i in resnet_variables if 'global_step' not in i.name]
if is_training and not reuse:
init_saver = tf.train.Saver(resnet_variables)
def init_fn(scaffold, sess):
del scaffold
init_saver.restore(sess, checkpoint)
else:
init_fn = None
return resnet_output, resnet_variables, init_fn
示例2: encoder_resnet
# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v2 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v2 import resnet_v2_50 [as 别名]
def encoder_resnet(x, is_training=True, weight_decay=0.001, reuse=False):
"""
Resnet v2-50
Assumes input is [batch, height_in, width_in, channels]!!
Input:
- x: N x H x W x 3
- weight_decay: float
- reuse: bool->True if test
Outputs:
- cam: N x 3
- Pose vector: N x 72
- Shape vector: N x 10
- variables: tf variables
"""
from tensorflow.contrib.slim.python.slim.nets import resnet_v2
with tf.name_scope('Encoder_resnet', values=[x]):
with slim.arg_scope(
resnet_v2.resnet_arg_scope(weight_decay=weight_decay)):
net, end_points = resnet_v2.resnet_v2_50(
x,
num_classes=None,
is_training=is_training,
reuse=reuse,
scope='resnet_v2_50')
net = tf.squeeze(net, axis=[1, 2])
variables_scope = 'resnet_v2_50'
return net, variables_scope
示例3: encoder_resnet
# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v2 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v2 import resnet_v2_50 [as 别名]
def encoder_resnet(x, is_training=True, weight_decay=0.001, reuse=False):
"""
Resnet v2-50
Assumes input is [batch, height_in, width_in, channels]!!
Input:
- x: N x H x W x 3
- weight_decay: float
- reuse: bool->True if test
Outputs:
- cam: N x 3
- Pose vector: N x 72
- Shape vector: N x 10
- variables: tf variables
"""
from tensorflow.contrib.slim.python.slim.nets import resnet_v2
with tf.name_scope('Encoder_resnet', [x]):
with slim.arg_scope(
resnet_v2.resnet_arg_scope(weight_decay=weight_decay)):
net, end_points = resnet_v2.resnet_v2_50(
x,
num_classes=None,
is_training=is_training,
reuse=reuse,
scope='resnet_v2_50')
net = tf.squeeze(net, axis=[1, 2])
variables_scope = 'resnet_v2_50'
return net, variables_scope
示例4: Encoder_resnet
# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v2 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v2 import resnet_v2_50 [as 别名]
def Encoder_resnet(x, is_training=True, weight_decay=0.001, reuse=False):
"""
Resnet v2-50
Assumes input is [batch, height_in, width_in, channels]!!
Input:
- x: N x H x W x 3
- weight_decay: float
- reuse: bool->True if test
Outputs:
- cam: N x 3
- Pose vector: N x 72
- Shape vector: N x 10
- variables: tf variables
"""
from tensorflow.contrib.slim.python.slim.nets import resnet_v2
with tf.name_scope("Encoder_resnet", [x]):
with slim.arg_scope(
resnet_v2.resnet_arg_scope(weight_decay=weight_decay)):
net, end_points = resnet_v2.resnet_v2_50(
x,
num_classes=None,
is_training=is_training,
reuse=reuse,
scope='resnet_v2_50')
net = tf.squeeze(net, axis=[1, 2])
variables = tf.contrib.framework.get_variables('resnet_v2_50')
return net, variables
示例5: network_resnet_v2_50
# 需要导入模块: from tensorflow.contrib.slim.python.slim.nets import resnet_v2 [as 别名]
# 或者: from tensorflow.contrib.slim.python.slim.nets.resnet_v2 import resnet_v2_50 [as 别名]
def network_resnet_v2_50():
input_shape = [1, 224, 224, 3]
input_ = tf.placeholder(dtype=tf.float32, name='input', shape=input_shape)
net, _end_points = resnet_v2_50(input_, num_classes=1000, is_training=False)
return net