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


Python text_format.Merge方法代码示例

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


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

示例1: load_labelmap

# 需要导入模块: from google.protobuf import text_format [as 别名]
# 或者: from google.protobuf.text_format import Merge [as 别名]
def load_labelmap(path):
  """Loads label map proto.

  Args:
    path: path to StringIntLabelMap proto text file.
  Returns:
    a StringIntLabelMapProto
  """
  with tf.gfile.GFile(path, 'r') as fid:
    label_map_string = fid.read()
    label_map = string_int_label_map_pb2.StringIntLabelMap()
    try:
      text_format.Merge(label_map_string, label_map)
    except text_format.ParseError:
      label_map.ParseFromString(label_map_string)
  _validate_label_map(label_map)
  return label_map 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:label_map_util.py

示例2: get_configs_from_pipeline_file

# 需要导入模块: from google.protobuf import text_format [as 别名]
# 或者: from google.protobuf.text_format import Merge [as 别名]
def get_configs_from_pipeline_file():
  """Reads evaluation configuration from a pipeline_pb2.TrainEvalPipelineConfig.

  Reads evaluation config from file specified by pipeline_config_path flag.

  Returns:
    model_config: a model_pb2.DetectionModel
    eval_config: a eval_pb2.EvalConfig
    input_config: a input_reader_pb2.InputReader
  """
  pipeline_config = pipeline_pb2.TrainEvalPipelineConfig()
  with tf.gfile.GFile(FLAGS.pipeline_config_path, 'r') as f:
    text_format.Merge(f.read(), pipeline_config)

  model_config = pipeline_config.model
  if FLAGS.eval_training_data:
    eval_config = pipeline_config.train_config
  else:
    eval_config = pipeline_config.eval_config
  input_config = pipeline_config.eval_input_reader

  return model_config, eval_config, input_config 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:24,代码来源:eval.py

示例3: test_build_non_max_suppressor_with_correct_parameters

# 需要导入模块: from google.protobuf import text_format [as 别名]
# 或者: from google.protobuf.text_format import Merge [as 别名]
def test_build_non_max_suppressor_with_correct_parameters(self):
    post_processing_text_proto = """
      batch_non_max_suppression {
        score_threshold: 0.7
        iou_threshold: 0.6
        max_detections_per_class: 100
        max_total_detections: 300
      }
    """
    post_processing_config = post_processing_pb2.PostProcessing()
    text_format.Merge(post_processing_text_proto, post_processing_config)
    non_max_suppressor, _ = post_processing_builder.build(
        post_processing_config)
    self.assertEqual(non_max_suppressor.keywords['max_size_per_class'], 100)
    self.assertEqual(non_max_suppressor.keywords['max_total_size'], 300)
    self.assertAlmostEqual(non_max_suppressor.keywords['score_thresh'], 0.7)
    self.assertAlmostEqual(non_max_suppressor.keywords['iou_thresh'], 0.6) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:post_processing_builder_test.py

示例4: test_build_normalize_image

# 需要导入模块: from google.protobuf import text_format [as 别名]
# 或者: from google.protobuf.text_format import Merge [as 别名]
def test_build_normalize_image(self):
    preprocessor_text_proto = """
    normalize_image {
      original_minval: 0.0
      original_maxval: 255.0
      target_minval: -1.0
      target_maxval: 1.0
    }
    """
    preprocessor_proto = preprocessor_pb2.PreprocessingStep()
    text_format.Merge(preprocessor_text_proto, preprocessor_proto)
    function, args = preprocessor_builder.build(preprocessor_proto)
    self.assertEqual(function, preprocessor.normalize_image)
    self.assertEqual(args, {
        'original_minval': 0.0,
        'original_maxval': 255.0,
        'target_minval': -1.0,
        'target_maxval': 1.0,
    }) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:21,代码来源:preprocessor_builder_test.py

示例5: test_explicit_fc_op_arg_scope_has_fully_connected_op

# 需要导入模块: from google.protobuf import text_format [as 别名]
# 或者: from google.protobuf.text_format import Merge [as 别名]
def test_explicit_fc_op_arg_scope_has_fully_connected_op(self):
    conv_hyperparams_text_proto = """
      op: FC
      regularizer {
        l1_regularizer {
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    scope = hyperparams_builder.build(conv_hyperparams_proto, is_training=True)
    self.assertTrue(self._get_scope_key(slim.fully_connected) in scope) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:18,代码来源:hyperparams_builder_test.py

示例6: test_separable_conv2d_and_conv2d_and_transpose_have_same_parameters

# 需要导入模块: from google.protobuf import text_format [as 别名]
# 或者: from google.protobuf.text_format import Merge [as 别名]
def test_separable_conv2d_and_conv2d_and_transpose_have_same_parameters(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l1_regularizer {
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    scope = hyperparams_builder.build(conv_hyperparams_proto, is_training=True)
    kwargs_1, kwargs_2, kwargs_3 = scope.values()
    self.assertDictEqual(kwargs_1, kwargs_2)
    self.assertDictEqual(kwargs_1, kwargs_3) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:hyperparams_builder_test.py

示例7: test_return_l2_regularizer_weights

# 需要导入模块: from google.protobuf import text_format [as 别名]
# 或者: from google.protobuf.text_format import Merge [as 别名]
def test_return_l2_regularizer_weights(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
          weight: 0.42
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    scope = hyperparams_builder.build(conv_hyperparams_proto, is_training=True)
    conv_scope_arguments = scope.values()[0]

    regularizer = conv_scope_arguments['weights_regularizer']
    weights = np.array([1., -1, 4., 2.])
    with self.test_session() as sess:
      result = sess.run(regularizer(tf.constant(weights)))
    self.assertAllClose(np.power(weights, 2).sum() / 2.0 * 0.42, result) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:24,代码来源:hyperparams_builder_test.py

示例8: test_do_not_use_batch_norm_if_default

# 需要导入模块: from google.protobuf import text_format [as 别名]
# 或者: from google.protobuf.text_format import Merge [as 别名]
def test_do_not_use_batch_norm_if_default(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    scope = hyperparams_builder.build(conv_hyperparams_proto, is_training=True)
    conv_scope_arguments = scope.values()[0]
    self.assertEqual(conv_scope_arguments['normalizer_fn'], None)
    self.assertEqual(conv_scope_arguments['normalizer_params'], None) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:hyperparams_builder_test.py

示例9: test_use_relu_activation

# 需要导入模块: from google.protobuf import text_format [as 别名]
# 或者: from google.protobuf.text_format import Merge [as 别名]
def test_use_relu_activation(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
      activation: RELU
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    scope = hyperparams_builder.build(conv_hyperparams_proto, is_training=True)
    conv_scope_arguments = scope.values()[0]
    self.assertEqual(conv_scope_arguments['activation_fn'], tf.nn.relu) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:hyperparams_builder_test.py

示例10: test_use_relu_6_activation

# 需要导入模块: from google.protobuf import text_format [as 别名]
# 或者: from google.protobuf.text_format import Merge [as 别名]
def test_use_relu_6_activation(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        truncated_normal_initializer {
        }
      }
      activation: RELU_6
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    scope = hyperparams_builder.build(conv_hyperparams_proto, is_training=True)
    conv_scope_arguments = scope.values()[0]
    self.assertEqual(conv_scope_arguments['activation_fn'], tf.nn.relu6) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:19,代码来源:hyperparams_builder_test.py

示例11: test_variance_in_range_with_variance_scaling_initializer_fan_in

# 需要导入模块: from google.protobuf import text_format [as 别名]
# 或者: from google.protobuf.text_format import Merge [as 别名]
def test_variance_in_range_with_variance_scaling_initializer_fan_in(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        variance_scaling_initializer {
          factor: 2.0
          mode: FAN_IN
          uniform: false
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    scope = hyperparams_builder.build(conv_hyperparams_proto, is_training=True)
    conv_scope_arguments = scope.values()[0]
    initializer = conv_scope_arguments['weights_initializer']
    self._assert_variance_in_range(initializer, shape=[100, 40],
                                   variance=2. / 100.) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:23,代码来源:hyperparams_builder_test.py

示例12: test_variance_in_range_with_variance_scaling_initializer_fan_out

# 需要导入模块: from google.protobuf import text_format [as 别名]
# 或者: from google.protobuf.text_format import Merge [as 别名]
def test_variance_in_range_with_variance_scaling_initializer_fan_out(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        variance_scaling_initializer {
          factor: 2.0
          mode: FAN_OUT
          uniform: false
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    scope = hyperparams_builder.build(conv_hyperparams_proto, is_training=True)
    conv_scope_arguments = scope.values()[0]
    initializer = conv_scope_arguments['weights_initializer']
    self._assert_variance_in_range(initializer, shape=[100, 40],
                                   variance=2. / 40.) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:23,代码来源:hyperparams_builder_test.py

示例13: test_variance_in_range_with_variance_scaling_initializer_fan_avg

# 需要导入模块: from google.protobuf import text_format [as 别名]
# 或者: from google.protobuf.text_format import Merge [as 别名]
def test_variance_in_range_with_variance_scaling_initializer_fan_avg(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        variance_scaling_initializer {
          factor: 2.0
          mode: FAN_AVG
          uniform: false
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    scope = hyperparams_builder.build(conv_hyperparams_proto, is_training=True)
    conv_scope_arguments = scope.values()[0]
    initializer = conv_scope_arguments['weights_initializer']
    self._assert_variance_in_range(initializer, shape=[100, 40],
                                   variance=4. / (100. + 40.)) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:23,代码来源:hyperparams_builder_test.py

示例14: test_variance_in_range_with_truncated_normal_initializer

# 需要导入模块: from google.protobuf import text_format [as 别名]
# 或者: from google.protobuf.text_format import Merge [as 别名]
def test_variance_in_range_with_truncated_normal_initializer(self):
    conv_hyperparams_text_proto = """
      regularizer {
        l2_regularizer {
        }
      }
      initializer {
        truncated_normal_initializer {
          mean: 0.0
          stddev: 0.8
        }
      }
    """
    conv_hyperparams_proto = hyperparams_pb2.Hyperparams()
    text_format.Merge(conv_hyperparams_text_proto, conv_hyperparams_proto)
    scope = hyperparams_builder.build(conv_hyperparams_proto, is_training=True)
    conv_scope_arguments = scope.values()[0]
    initializer = conv_scope_arguments['weights_initializer']
    self._assert_variance_in_range(initializer, shape=[100, 40],
                                   variance=0.49, tol=1e-1) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:22,代码来源:hyperparams_builder_test.py

示例15: testBuildManualStepLearningRate

# 需要导入模块: from google.protobuf import text_format [as 别名]
# 或者: from google.protobuf.text_format import Merge [as 别名]
def testBuildManualStepLearningRate(self):
    learning_rate_text_proto = """
      manual_step_learning_rate {
        schedule {
          step: 0
          learning_rate: 0.006
        }
        schedule {
          step: 90000
          learning_rate: 0.00006
        }
      }
    """
    global_summaries = set([])
    learning_rate_proto = optimizer_pb2.LearningRate()
    text_format.Merge(learning_rate_text_proto, learning_rate_proto)
    learning_rate = optimizer_builder._create_learning_rate(
        learning_rate_proto, global_summaries)
    self.assertTrue(isinstance(learning_rate, tf.Tensor)) 
开发者ID:ringringyi,项目名称:DOTA_models,代码行数:21,代码来源:optimizer_builder_test.py


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