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


Python vgg.vgg_16方法代码示例

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


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

示例1: model

# 需要导入模块: from nets import vgg [as 别名]
# 或者: from nets.vgg import vgg_16 [as 别名]
def model(image):
    image = mean_image_subtraction(image)
    with slim.arg_scope(vgg.vgg_arg_scope()):
        conv5_3 = vgg.vgg_16(image)

    rpn_conv = slim.conv2d(conv5_3, 512, 3)

    lstm_output = Bilstm(rpn_conv, 512, 128, 512, scope_name='BiLSTM')

    bbox_pred = lstm_fc(lstm_output, 512, 10 * 4, scope_name="bbox_pred")
    cls_pred = lstm_fc(lstm_output, 512, 10 * 2, scope_name="cls_pred")

    # transpose: (1, H, W, A x d) -> (1, H, WxA, d)
    cls_pred_shape = tf.shape(cls_pred)
    cls_pred_reshape = tf.reshape(cls_pred, [cls_pred_shape[0], cls_pred_shape[1], -1, 2])

    cls_pred_reshape_shape = tf.shape(cls_pred_reshape)
    cls_prob = tf.reshape(tf.nn.softmax(tf.reshape(cls_pred_reshape, [-1, cls_pred_reshape_shape[3]])),
                          [-1, cls_pred_reshape_shape[1], cls_pred_reshape_shape[2], cls_pred_reshape_shape[3]],
                          name="cls_prob")

    return bbox_pred, cls_pred, cls_prob 
开发者ID:zzzDavid,项目名称:ICDAR-2019-SROIE,代码行数:24,代码来源:model_train.py

示例2: testTrainEvalWithReuse

# 需要导入模块: from nets import vgg [as 别名]
# 或者: from nets.vgg import vgg_16 [as 别名]
def testTrainEvalWithReuse(self):
    train_batch_size = 2
    eval_batch_size = 1
    train_height, train_width = 224, 224
    eval_height, eval_width = 256, 256
    num_classes = 1000
    with self.test_session():
      train_inputs = tf.random_uniform(
          (train_batch_size, train_height, train_width, 3))
      logits, _ = vgg.vgg_16(train_inputs)
      self.assertListEqual(logits.get_shape().as_list(),
                           [train_batch_size, num_classes])
      tf.get_variable_scope().reuse_variables()
      eval_inputs = tf.random_uniform(
          (eval_batch_size, eval_height, eval_width, 3))
      logits, _ = vgg.vgg_16(eval_inputs, is_training=False,
                             spatial_squeeze=False)
      self.assertListEqual(logits.get_shape().as_list(),
                           [eval_batch_size, 2, 2, num_classes])
      logits = tf.reduce_mean(logits, [1, 2])
      predictions = tf.argmax(logits, 1)
      self.assertEquals(predictions.get_shape().as_list(), [eval_batch_size]) 
开发者ID:leimao,项目名称:DeepLab_v3,代码行数:24,代码来源:vgg_test.py

示例3: testBuild

# 需要导入模块: from nets import vgg [as 别名]
# 或者: from nets.vgg import vgg_16 [as 别名]
def testBuild(self):
    batch_size = 5
    height, width = 224, 224
    num_classes = 1000
    with self.test_session():
      inputs = tf.random_uniform((batch_size, height, width, 3))
      logits, _ = vgg.vgg_16(inputs, num_classes)
      self.assertEquals(logits.op.name, 'vgg_16/fc8/squeezed')
      self.assertListEqual(logits.get_shape().as_list(),
                           [batch_size, num_classes]) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:12,代码来源:vgg_test.py

示例4: testFullyConvolutional

# 需要导入模块: from nets import vgg [as 别名]
# 或者: from nets.vgg import vgg_16 [as 别名]
def testFullyConvolutional(self):
    batch_size = 1
    height, width = 256, 256
    num_classes = 1000
    with self.test_session():
      inputs = tf.random_uniform((batch_size, height, width, 3))
      logits, _ = vgg.vgg_16(inputs, num_classes, spatial_squeeze=False)
      self.assertEquals(logits.op.name, 'vgg_16/fc8/BiasAdd')
      self.assertListEqual(logits.get_shape().as_list(),
                           [batch_size, 2, 2, num_classes]) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:12,代码来源:vgg_test.py

示例5: testEndPoints

# 需要导入模块: from nets import vgg [as 别名]
# 或者: from nets.vgg import vgg_16 [as 别名]
def testEndPoints(self):
    batch_size = 5
    height, width = 224, 224
    num_classes = 1000
    with self.test_session():
      inputs = tf.random_uniform((batch_size, height, width, 3))
      _, end_points = vgg.vgg_16(inputs, num_classes)
      expected_names = ['vgg_16/conv1/conv1_1',
                        'vgg_16/conv1/conv1_2',
                        'vgg_16/pool1',
                        'vgg_16/conv2/conv2_1',
                        'vgg_16/conv2/conv2_2',
                        'vgg_16/pool2',
                        'vgg_16/conv3/conv3_1',
                        'vgg_16/conv3/conv3_2',
                        'vgg_16/conv3/conv3_3',
                        'vgg_16/pool3',
                        'vgg_16/conv4/conv4_1',
                        'vgg_16/conv4/conv4_2',
                        'vgg_16/conv4/conv4_3',
                        'vgg_16/pool4',
                        'vgg_16/conv5/conv5_1',
                        'vgg_16/conv5/conv5_2',
                        'vgg_16/conv5/conv5_3',
                        'vgg_16/pool5',
                        'vgg_16/fc6',
                        'vgg_16/fc7',
                        'vgg_16/fc8'
                       ]
      self.assertSetEqual(set(end_points.keys()), set(expected_names)) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:32,代码来源:vgg_test.py

示例6: testEvaluation

# 需要导入模块: from nets import vgg [as 别名]
# 或者: from nets.vgg import vgg_16 [as 别名]
def testEvaluation(self):
    batch_size = 2
    height, width = 224, 224
    num_classes = 1000
    with self.test_session():
      eval_inputs = tf.random_uniform((batch_size, height, width, 3))
      logits, _ = vgg.vgg_16(eval_inputs, is_training=False)
      self.assertListEqual(logits.get_shape().as_list(),
                           [batch_size, num_classes])
      predictions = tf.argmax(logits, 1)
      self.assertListEqual(predictions.get_shape().as_list(), [batch_size]) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:13,代码来源:vgg_test.py

示例7: testForward

# 需要导入模块: from nets import vgg [as 别名]
# 或者: from nets.vgg import vgg_16 [as 别名]
def testForward(self):
    batch_size = 1
    height, width = 224, 224
    with self.test_session() as sess:
      inputs = tf.random_uniform((batch_size, height, width, 3))
      logits, _ = vgg.vgg_16(inputs)
      sess.run(tf.global_variables_initializer())
      output = sess.run(logits)
      self.assertTrue(output.any()) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:11,代码来源:vgg_test.py

示例8: testGlobalPool

# 需要导入模块: from nets import vgg [as 别名]
# 或者: from nets.vgg import vgg_16 [as 别名]
def testGlobalPool(self):
    batch_size = 1
    height, width = 256, 256
    num_classes = 1000
    with self.test_session():
      inputs = tf.random_uniform((batch_size, height, width, 3))
      logits, _ = vgg.vgg_16(inputs, num_classes, spatial_squeeze=False,
                             global_pool=True)
      self.assertEquals(logits.op.name, 'vgg_16/fc8/BiasAdd')
      self.assertListEqual(logits.get_shape().as_list(),
                           [batch_size, 1, 1, num_classes]) 
开发者ID:leimao,项目名称:DeepLab_v3,代码行数:13,代码来源:vgg_test.py

示例9: testNoClasses

# 需要导入模块: from nets import vgg [as 别名]
# 或者: from nets.vgg import vgg_16 [as 别名]
def testNoClasses(self):
    batch_size = 5
    height, width = 224, 224
    num_classes = None
    with self.test_session():
      inputs = tf.random_uniform((batch_size, height, width, 3))
      net, end_points = vgg.vgg_16(inputs, num_classes)
      expected_names = ['vgg_16/conv1/conv1_1',
                        'vgg_16/conv1/conv1_2',
                        'vgg_16/pool1',
                        'vgg_16/conv2/conv2_1',
                        'vgg_16/conv2/conv2_2',
                        'vgg_16/pool2',
                        'vgg_16/conv3/conv3_1',
                        'vgg_16/conv3/conv3_2',
                        'vgg_16/conv3/conv3_3',
                        'vgg_16/pool3',
                        'vgg_16/conv4/conv4_1',
                        'vgg_16/conv4/conv4_2',
                        'vgg_16/conv4/conv4_3',
                        'vgg_16/pool4',
                        'vgg_16/conv5/conv5_1',
                        'vgg_16/conv5/conv5_2',
                        'vgg_16/conv5/conv5_3',
                        'vgg_16/pool5',
                        'vgg_16/fc6',
                        'vgg_16/fc7',
                       ]
      self.assertSetEqual(set(end_points.keys()), set(expected_names))
      self.assertTrue(net.op.name.startswith('vgg_16/fc7')) 
开发者ID:leimao,项目名称:DeepLab_v3,代码行数:32,代码来源:vgg_test.py


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