本文整理匯總了Python中nets.mobilenet.mobilenet_v2.mobilenet方法的典型用法代碼示例。如果您正苦於以下問題:Python mobilenet_v2.mobilenet方法的具體用法?Python mobilenet_v2.mobilenet怎麽用?Python mobilenet_v2.mobilenet使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類nets.mobilenet.mobilenet_v2
的用法示例。
在下文中一共展示了mobilenet_v2.mobilenet方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testCreation
# 需要導入模塊: from nets.mobilenet import mobilenet_v2 [as 別名]
# 或者: from nets.mobilenet.mobilenet_v2 import mobilenet [as 別名]
def testCreation(self):
spec = dict(mobilenet_v2.V2_DEF)
_, ep = mobilenet.mobilenet(
tf.placeholder(tf.float32, (10, 224, 224, 16)), conv_defs=spec)
num_convs = len(find_ops('Conv2D'))
# This is mostly a sanity test. No deep reason for these particular
# constants.
#
# All but first 2 and last one have two convolutions, and there is one
# extra conv that is not in the spec. (logits)
self.assertEqual(num_convs, len(spec['spec']) * 2 - 2)
# Check that depthwise are exposed.
for i in range(2, 17):
self.assertIn('layer_%d/depthwise_output' % i, ep)
示例2: testCreationNoClasses
# 需要導入模塊: from nets.mobilenet import mobilenet_v2 [as 別名]
# 或者: from nets.mobilenet.mobilenet_v2 import mobilenet [as 別名]
def testCreationNoClasses(self):
spec = copy.deepcopy(mobilenet_v2.V2_DEF)
net, ep = mobilenet.mobilenet(
tf.placeholder(tf.float32, (10, 224, 224, 16)), conv_defs=spec,
num_classes=None)
self.assertIs(net, ep['global_pool'])
示例3: testImageSizes
# 需要導入模塊: from nets.mobilenet import mobilenet_v2 [as 別名]
# 或者: from nets.mobilenet.mobilenet_v2 import mobilenet [as 別名]
def testImageSizes(self):
for input_size, output_size in [(224, 7), (192, 6), (160, 5),
(128, 4), (96, 3)]:
tf.reset_default_graph()
_, ep = mobilenet_v2.mobilenet(
tf.placeholder(tf.float32, (10, input_size, input_size, 3)))
self.assertEqual(ep['layer_18/output'].get_shape().as_list()[1:3],
[output_size] * 2)
示例4: testWithSplits
# 需要導入模塊: from nets.mobilenet import mobilenet_v2 [as 別名]
# 或者: from nets.mobilenet.mobilenet_v2 import mobilenet [as 別名]
def testWithSplits(self):
spec = copy.deepcopy(mobilenet_v2.V2_DEF)
spec['overrides'] = {
(ops.expanded_conv,): dict(split_expansion=2),
}
_, _ = mobilenet.mobilenet(
tf.placeholder(tf.float32, (10, 224, 224, 16)), conv_defs=spec)
num_convs = len(find_ops('Conv2D'))
# All but 3 op has 3 conv operatore, the remainign 3 have one
# and there is one unaccounted.
self.assertEqual(num_convs, len(spec['spec']) * 3 - 5)
示例5: testWithOutputStride8
# 需要導入模塊: from nets.mobilenet import mobilenet_v2 [as 別名]
# 或者: from nets.mobilenet.mobilenet_v2 import mobilenet [as 別名]
def testWithOutputStride8(self):
out, _ = mobilenet.mobilenet_base(
tf.placeholder(tf.float32, (10, 224, 224, 16)),
conv_defs=mobilenet_v2.V2_DEF,
output_stride=8,
scope='MobilenetV2')
self.assertEqual(out.get_shape().as_list()[1:3], [28, 28])
示例6: testDivisibleByWithArgScope
# 需要導入模塊: from nets.mobilenet import mobilenet_v2 [as 別名]
# 或者: from nets.mobilenet.mobilenet_v2 import mobilenet [as 別名]
def testDivisibleByWithArgScope(self):
tf.reset_default_graph()
# Verifies that depth_multiplier arg scope actually works
# if no default min_depth is provided.
with slim.arg_scope((mobilenet.depth_multiplier,), min_depth=32):
mobilenet_v2.mobilenet(
tf.placeholder(tf.float32, (10, 224, 224, 2)),
conv_defs=mobilenet_v2.V2_DEF, depth_multiplier=0.1)
s = [op.outputs[0].get_shape().as_list()[-1] for op in find_ops('Conv2D')]
s = set(s)
self.assertSameElements(s, [32, 192, 128, 1001])
示例7: testFineGrained
# 需要導入模塊: from nets.mobilenet import mobilenet_v2 [as 別名]
# 或者: from nets.mobilenet.mobilenet_v2 import mobilenet [as 別名]
def testFineGrained(self):
tf.reset_default_graph()
# Verifies that depth_multiplier arg scope actually works
# if no default min_depth is provided.
mobilenet_v2.mobilenet(
tf.placeholder(tf.float32, (10, 224, 224, 2)),
conv_defs=mobilenet_v2.V2_DEF, depth_multiplier=0.01,
finegrain_classification_mode=True)
s = [op.outputs[0].get_shape().as_list()[-1] for op in find_ops('Conv2D')]
s = set(s)
# All convolutions will be 8->48, except for the last one.
self.assertSameElements(s, [8, 48, 1001, 1280])
示例8: testMobilenetBase
# 需要導入模塊: from nets.mobilenet import mobilenet_v2 [as 別名]
# 或者: from nets.mobilenet.mobilenet_v2 import mobilenet [as 別名]
def testMobilenetBase(self):
tf.reset_default_graph()
# Verifies that mobilenet_base returns pre-pooling layer.
with slim.arg_scope((mobilenet.depth_multiplier,), min_depth=32):
net, _ = mobilenet_v2.mobilenet_base(
tf.placeholder(tf.float32, (10, 224, 224, 16)),
conv_defs=mobilenet_v2.V2_DEF, depth_multiplier=0.1)
self.assertEqual(net.get_shape().as_list(), [10, 7, 7, 128])
示例9: testWithOutputStride16
# 需要導入模塊: from nets.mobilenet import mobilenet_v2 [as 別名]
# 或者: from nets.mobilenet.mobilenet_v2 import mobilenet [as 別名]
def testWithOutputStride16(self):
tf.reset_default_graph()
out, _ = mobilenet.mobilenet_base(
tf.placeholder(tf.float32, (10, 224, 224, 16)),
conv_defs=mobilenet_v2.V2_DEF,
output_stride=16)
self.assertEqual(out.get_shape().as_list()[1:3], [14, 14])
示例10: testWithOutputStride8AndExplicitPadding
# 需要導入模塊: from nets.mobilenet import mobilenet_v2 [as 別名]
# 或者: from nets.mobilenet.mobilenet_v2 import mobilenet [as 別名]
def testWithOutputStride8AndExplicitPadding(self):
tf.reset_default_graph()
out, _ = mobilenet.mobilenet_base(
tf.placeholder(tf.float32, (10, 224, 224, 16)),
conv_defs=mobilenet_v2.V2_DEF,
output_stride=8,
use_explicit_padding=True,
scope='MobilenetV2')
self.assertEqual(out.get_shape().as_list()[1:3], [28, 28])
示例11: testBatchNormScopeDoesNotHaveIsTrainingWhenItsSetToNone
# 需要導入模塊: from nets.mobilenet import mobilenet_v2 [as 別名]
# 或者: from nets.mobilenet.mobilenet_v2 import mobilenet [as 別名]
def testBatchNormScopeDoesNotHaveIsTrainingWhenItsSetToNone(self):
sc = mobilenet.training_scope(is_training=None)
self.assertNotIn('is_training', sc[slim.arg_scope_func_key(
slim.batch_norm)])
示例12: testBatchNormScopeDoesHasIsTrainingWhenItsNotNone
# 需要導入模塊: from nets.mobilenet import mobilenet_v2 [as 別名]
# 或者: from nets.mobilenet.mobilenet_v2 import mobilenet [as 別名]
def testBatchNormScopeDoesHasIsTrainingWhenItsNotNone(self):
sc = mobilenet.training_scope(is_training=False)
self.assertIn('is_training', sc[slim.arg_scope_func_key(slim.batch_norm)])
sc = mobilenet.training_scope(is_training=True)
self.assertIn('is_training', sc[slim.arg_scope_func_key(slim.batch_norm)])
sc = mobilenet.training_scope()
self.assertIn('is_training', sc[slim.arg_scope_func_key(slim.batch_norm)])