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


Python nasnet.nasnet_mobile_arg_scope方法代碼示例

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


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

示例1: testBuildLogitsMobileModel

# 需要導入模塊: from nets.nasnet import nasnet [as 別名]
# 或者: from nets.nasnet.nasnet import nasnet_mobile_arg_scope [as 別名]
def testBuildLogitsMobileModel(self):
    batch_size = 5
    height, width = 224, 224
    num_classes = 1000
    inputs = tf.random_uniform((batch_size, height, width, 3))
    tf.train.create_global_step()
    with slim.arg_scope(nasnet.nasnet_mobile_arg_scope()):
      logits, end_points = nasnet.build_nasnet_mobile(inputs, num_classes)
    auxlogits = end_points['AuxLogits']
    predictions = end_points['Predictions']
    self.assertListEqual(auxlogits.get_shape().as_list(),
                         [batch_size, num_classes])
    self.assertListEqual(logits.get_shape().as_list(),
                         [batch_size, num_classes])
    self.assertListEqual(predictions.get_shape().as_list(),
                         [batch_size, num_classes]) 
開發者ID:leimao,項目名稱:DeepLab_v3,代碼行數:18,代碼來源:nasnet_test.py

示例2: testVariablesSetDeviceMobileModel

# 需要導入模塊: from nets.nasnet import nasnet [as 別名]
# 或者: from nets.nasnet.nasnet import nasnet_mobile_arg_scope [as 別名]
def testVariablesSetDeviceMobileModel(self):
    batch_size = 5
    height, width = 224, 224
    num_classes = 1000
    inputs = tf.random_uniform((batch_size, height, width, 3))
    tf.train.create_global_step()
    # Force all Variables to reside on the device.
    with tf.variable_scope('on_cpu'), tf.device('/cpu:0'):
      with slim.arg_scope(nasnet.nasnet_mobile_arg_scope()):
        nasnet.build_nasnet_mobile(inputs, num_classes)
    with tf.variable_scope('on_gpu'), tf.device('/gpu:0'):
      with slim.arg_scope(nasnet.nasnet_mobile_arg_scope()):
        nasnet.build_nasnet_mobile(inputs, num_classes)
    for v in tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope='on_cpu'):
      self.assertDeviceEqual(v.device, '/cpu:0')
    for v in tf.get_collection(tf.GraphKeys.GLOBAL_VARIABLES, scope='on_gpu'):
      self.assertDeviceEqual(v.device, '/gpu:0') 
開發者ID:SrikanthVelpuri,項目名稱:tf-pose,代碼行數:19,代碼來源:nasnet_test.py

示例3: pnasnet_mobile_arg_scope

# 需要導入模塊: from nets.nasnet import nasnet [as 別名]
# 或者: from nets.nasnet.nasnet import nasnet_mobile_arg_scope [as 別名]
def pnasnet_mobile_arg_scope(weight_decay=4e-5,
                             batch_norm_decay=0.9997,
                             batch_norm_epsilon=0.001):
  """Default arg scope for the PNASNet Mobile ImageNet model."""
  return nasnet.nasnet_mobile_arg_scope(weight_decay, batch_norm_decay,
                                        batch_norm_epsilon) 
開發者ID:leimao,項目名稱:DeepLab_v3,代碼行數:8,代碼來源:pnasnet.py

示例4: testBuildPreLogitsMobileModel

# 需要導入模塊: from nets.nasnet import nasnet [as 別名]
# 或者: from nets.nasnet.nasnet import nasnet_mobile_arg_scope [as 別名]
def testBuildPreLogitsMobileModel(self):
    batch_size = 5
    height, width = 224, 224
    num_classes = None
    inputs = tf.random_uniform((batch_size, height, width, 3))
    tf.train.create_global_step()
    with slim.arg_scope(nasnet.nasnet_mobile_arg_scope()):
      net, end_points = nasnet.build_nasnet_mobile(inputs, num_classes)
    self.assertFalse('AuxLogits' in end_points)
    self.assertFalse('Predictions' in end_points)
    self.assertTrue(net.op.name.startswith('final_layer/Mean'))
    self.assertListEqual(net.get_shape().as_list(), [batch_size, 1056]) 
開發者ID:leimao,項目名稱:DeepLab_v3,代碼行數:14,代碼來源:nasnet_test.py

示例5: testAllEndPointsShapesMobileModel

# 需要導入模塊: from nets.nasnet import nasnet [as 別名]
# 或者: from nets.nasnet.nasnet import nasnet_mobile_arg_scope [as 別名]
def testAllEndPointsShapesMobileModel(self):
    batch_size = 5
    height, width = 224, 224
    num_classes = 1000
    inputs = tf.random_uniform((batch_size, height, width, 3))
    tf.train.create_global_step()
    with slim.arg_scope(nasnet.nasnet_mobile_arg_scope()):
      _, end_points = nasnet.build_nasnet_mobile(inputs, num_classes)
    endpoints_shapes = {'Stem': [batch_size, 28, 28, 88],
                        'Cell_0': [batch_size, 28, 28, 264],
                        'Cell_1': [batch_size, 28, 28, 264],
                        'Cell_2': [batch_size, 28, 28, 264],
                        'Cell_3': [batch_size, 28, 28, 264],
                        'Cell_4': [batch_size, 14, 14, 528],
                        'Cell_5': [batch_size, 14, 14, 528],
                        'Cell_6': [batch_size, 14, 14, 528],
                        'Cell_7': [batch_size, 14, 14, 528],
                        'Cell_8': [batch_size, 7, 7, 1056],
                        'Cell_9': [batch_size, 7, 7, 1056],
                        'Cell_10': [batch_size, 7, 7, 1056],
                        'Cell_11': [batch_size, 7, 7, 1056],
                        'Reduction_Cell_0': [batch_size, 14, 14, 352],
                        'Reduction_Cell_1': [batch_size, 7, 7, 704],
                        'global_pool': [batch_size, 1056],
                        # Logits and predictions
                        'AuxLogits': [batch_size, num_classes],
                        'Logits': [batch_size, num_classes],
                        'Predictions': [batch_size, num_classes]}
    self.assertItemsEqual(endpoints_shapes.keys(), end_points.keys())
    for endpoint_name in endpoints_shapes:
      tf.logging.info('Endpoint name: {}'.format(endpoint_name))
      expected_shape = endpoints_shapes[endpoint_name]
      self.assertTrue(endpoint_name in end_points)
      self.assertListEqual(end_points[endpoint_name].get_shape().as_list(),
                           expected_shape) 
開發者ID:leimao,項目名稱:DeepLab_v3,代碼行數:37,代碼來源:nasnet_test.py

示例6: testNoAuxHeadMobileModel

# 需要導入模塊: from nets.nasnet import nasnet [as 別名]
# 或者: from nets.nasnet.nasnet import nasnet_mobile_arg_scope [as 別名]
def testNoAuxHeadMobileModel(self):
    batch_size = 5
    height, width = 224, 224
    num_classes = 1000
    for use_aux_head in (True, False):
      tf.reset_default_graph()
      inputs = tf.random_uniform((batch_size, height, width, 3))
      tf.train.create_global_step()
      config = nasnet.mobile_imagenet_config()
      config.set_hparam('use_aux_head', int(use_aux_head))
      with slim.arg_scope(nasnet.nasnet_mobile_arg_scope()):
        _, end_points = nasnet.build_nasnet_mobile(inputs, num_classes,
                                                   config=config)
      self.assertEqual('AuxLogits' in end_points, use_aux_head) 
開發者ID:leimao,項目名稱:DeepLab_v3,代碼行數:16,代碼來源:nasnet_test.py

示例7: testUnknownBatchSizeMobileModel

# 需要導入模塊: from nets.nasnet import nasnet [as 別名]
# 或者: from nets.nasnet.nasnet import nasnet_mobile_arg_scope [as 別名]
def testUnknownBatchSizeMobileModel(self):
    batch_size = 1
    height, width = 224, 224
    num_classes = 1000
    with self.test_session() as sess:
      inputs = tf.placeholder(tf.float32, (None, height, width, 3))
      with slim.arg_scope(nasnet.nasnet_mobile_arg_scope()):
        logits, _ = nasnet.build_nasnet_mobile(inputs, num_classes)
      self.assertListEqual(logits.get_shape().as_list(),
                           [None, num_classes])
      images = tf.random_uniform((batch_size, height, width, 3))
      sess.run(tf.global_variables_initializer())
      output = sess.run(logits, {inputs: images.eval()})
      self.assertEquals(output.shape, (batch_size, num_classes)) 
開發者ID:leimao,項目名稱:DeepLab_v3,代碼行數:16,代碼來源:nasnet_test.py

示例8: testEvaluationMobileModel

# 需要導入模塊: from nets.nasnet import nasnet [as 別名]
# 或者: from nets.nasnet.nasnet import nasnet_mobile_arg_scope [as 別名]
def testEvaluationMobileModel(self):
    batch_size = 2
    height, width = 224, 224
    num_classes = 1000
    with self.test_session() as sess:
      eval_inputs = tf.random_uniform((batch_size, height, width, 3))
      with slim.arg_scope(nasnet.nasnet_mobile_arg_scope()):
        logits, _ = nasnet.build_nasnet_mobile(eval_inputs,
                                               num_classes,
                                               is_training=False)
      predictions = tf.argmax(logits, 1)
      sess.run(tf.global_variables_initializer())
      output = sess.run(predictions)
      self.assertEquals(output.shape, (batch_size,)) 
開發者ID:leimao,項目名稱:DeepLab_v3,代碼行數:16,代碼來源:nasnet_test.py

示例9: testOverrideHParamsMobileModel

# 需要導入模塊: from nets.nasnet import nasnet [as 別名]
# 或者: from nets.nasnet.nasnet import nasnet_mobile_arg_scope [as 別名]
def testOverrideHParamsMobileModel(self):
    batch_size = 5
    height, width = 224, 224
    num_classes = 1000
    inputs = tf.random_uniform((batch_size, height, width, 3))
    tf.train.create_global_step()
    config = nasnet.mobile_imagenet_config()
    config.set_hparam('data_format', 'NCHW')
    with slim.arg_scope(nasnet.nasnet_mobile_arg_scope()):
      _, end_points = nasnet.build_nasnet_mobile(
          inputs, num_classes, config=config)
    self.assertListEqual(
        end_points['Stem'].shape.as_list(), [batch_size, 88, 28, 28]) 
開發者ID:leimao,項目名稱:DeepLab_v3,代碼行數:15,代碼來源:nasnet_test.py


注:本文中的nets.nasnet.nasnet.nasnet_mobile_arg_scope方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。