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


Python mobilenet_v1.Conv方法代码示例

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


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

示例1: testBuildCustomNetworkUsingConvDefs

# 需要导入模块: from nets import mobilenet_v1 [as 别名]
# 或者: from nets.mobilenet_v1 import Conv [as 别名]
def testBuildCustomNetworkUsingConvDefs(self):
    batch_size = 5
    height, width = 224, 224
    conv_defs = [
        mobilenet_v1.Conv(kernel=[3, 3], stride=2, depth=32),
        mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=1, depth=64),
        mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=2, depth=128),
        mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=1, depth=512)
    ]

    inputs = tf.random_uniform((batch_size, height, width, 3))
    net, end_points = mobilenet_v1.mobilenet_v1_base(
        inputs, final_endpoint='Conv2d_3_pointwise', conv_defs=conv_defs)
    self.assertTrue(net.op.name.startswith('MobilenetV1/Conv2d_3'))
    self.assertListEqual(net.get_shape().as_list(),
                         [batch_size, 56, 56, 512])
    expected_endpoints = ['Conv2d_0',
                          'Conv2d_1_depthwise', 'Conv2d_1_pointwise',
                          'Conv2d_2_depthwise', 'Conv2d_2_pointwise',
                          'Conv2d_3_depthwise', 'Conv2d_3_pointwise']
    self.assertItemsEqual(end_points.keys(), expected_endpoints) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:23,代码来源:mobilenet_v1_test.py

示例2: testBuildEndPointsWithDepthMultiplierLessThanOne

# 需要导入模块: from nets import mobilenet_v1 [as 别名]
# 或者: from nets.mobilenet_v1 import Conv [as 别名]
def testBuildEndPointsWithDepthMultiplierLessThanOne(self):
    batch_size = 5
    height, width = 224, 224
    num_classes = 1000

    inputs = tf.random_uniform((batch_size, height, width, 3))
    _, end_points = mobilenet_v1.mobilenet_v1(inputs, num_classes)

    endpoint_keys = [key for key in end_points.keys() if key.startswith('Conv')]

    _, end_points_with_multiplier = mobilenet_v1.mobilenet_v1(
        inputs, num_classes, scope='depth_multiplied_net',
        depth_multiplier=0.5)

    for key in endpoint_keys:
      original_depth = end_points[key].get_shape().as_list()[3]
      new_depth = end_points_with_multiplier[key].get_shape().as_list()[3]
      self.assertEqual(0.5 * original_depth, new_depth) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:20,代码来源:mobilenet_v1_test.py

示例3: testBuildEndPointsWithDepthMultiplierGreaterThanOne

# 需要导入模块: from nets import mobilenet_v1 [as 别名]
# 或者: from nets.mobilenet_v1 import Conv [as 别名]
def testBuildEndPointsWithDepthMultiplierGreaterThanOne(self):
    batch_size = 5
    height, width = 224, 224
    num_classes = 1000

    inputs = tf.random_uniform((batch_size, height, width, 3))
    _, end_points = mobilenet_v1.mobilenet_v1(inputs, num_classes)

    endpoint_keys = [key for key in end_points.keys()
                     if key.startswith('Mixed') or key.startswith('Conv')]

    _, end_points_with_multiplier = mobilenet_v1.mobilenet_v1(
        inputs, num_classes, scope='depth_multiplied_net',
        depth_multiplier=2.0)

    for key in endpoint_keys:
      original_depth = end_points[key].get_shape().as_list()[3]
      new_depth = end_points_with_multiplier[key].get_shape().as_list()[3]
      self.assertEqual(2.0 * original_depth, new_depth) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:21,代码来源:mobilenet_v1_test.py

示例4: _get_mobilenet_conv_no_last_stride_defs

# 需要导入模块: from nets import mobilenet_v1 [as 别名]
# 或者: from nets.mobilenet_v1 import Conv [as 别名]
def _get_mobilenet_conv_no_last_stride_defs(conv_depth_ratio_in_percentage):
  if conv_depth_ratio_in_percentage not in [25, 50, 75, 100]:
    raise ValueError(
        'Only the following ratio percentages are supported: 25, 50, 75, 100')
  conv_depth_ratio_in_percentage = float(conv_depth_ratio_in_percentage) / 100.0
  channels = np.array([
      32, 64, 128, 128, 256, 256, 512, 512, 512, 512, 512, 512, 1024, 1024
  ], dtype=np.float32)
  channels = (channels * conv_depth_ratio_in_percentage).astype(np.int32)
  return [
      mobilenet_v1.Conv(kernel=[3, 3], stride=2, depth=channels[0]),
      mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=1, depth=channels[1]),
      mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=2, depth=channels[2]),
      mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=1, depth=channels[3]),
      mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=2, depth=channels[4]),
      mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=1, depth=channels[5]),
      mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=2, depth=channels[6]),
      mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=1, depth=channels[7]),
      mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=1, depth=channels[8]),
      mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=1, depth=channels[9]),
      mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=1, depth=channels[10]),
      mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=1, depth=channels[11]),
      mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=1, depth=channels[12]),
      mobilenet_v1.DepthSepConv(kernel=[3, 3], stride=1, depth=channels[13])
  ] 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:27,代码来源:faster_rcnn_mobilenet_v1_feature_extractor.py


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