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


Python exporter.replace_variable_values_with_moving_averages方法代码示例

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


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

示例1: test_replace_variable_values_with_moving_averages

# 需要导入模块: from object_detection import exporter [as 别名]
# 或者: from object_detection.exporter import replace_variable_values_with_moving_averages [as 别名]
def test_replace_variable_values_with_moving_averages(self):
    tmp_dir = self.get_temp_dir()
    trained_checkpoint_prefix = os.path.join(tmp_dir, 'model.ckpt')
    new_checkpoint_prefix = os.path.join(tmp_dir, 'new.ckpt')
    self._save_checkpoint_from_mock_model(trained_checkpoint_prefix,
                                          use_moving_averages=True)
    graph = tf.Graph()
    with graph.as_default():
      fake_model = FakeModel()
      preprocessed_inputs, true_image_shapes = fake_model.preprocess(
          tf.placeholder(dtype=tf.float32, shape=[None, None, None, 3]))
      predictions = fake_model.predict(preprocessed_inputs, true_image_shapes)
      fake_model.postprocess(predictions, true_image_shapes)
      exporter.replace_variable_values_with_moving_averages(
          graph, trained_checkpoint_prefix, new_checkpoint_prefix)

    expected_variables = set(['conv2d/bias', 'conv2d/kernel'])
    variables_in_old_ckpt = self._get_variables_in_checkpoint(
        trained_checkpoint_prefix)
    self.assertIn('conv2d/bias/ExponentialMovingAverage',
                  variables_in_old_ckpt)
    self.assertIn('conv2d/kernel/ExponentialMovingAverage',
                  variables_in_old_ckpt)
    variables_in_new_ckpt = self._get_variables_in_checkpoint(
        new_checkpoint_prefix)
    self.assertTrue(expected_variables.issubset(variables_in_new_ckpt))
    self.assertNotIn('conv2d/bias/ExponentialMovingAverage',
                     variables_in_new_ckpt)
    self.assertNotIn('conv2d/kernel/ExponentialMovingAverage',
                     variables_in_new_ckpt) 
开发者ID:ahmetozlu,项目名称:vehicle_counting_tensorflow,代码行数:32,代码来源:exporter_test.py

示例2: test_replace_variable_values_with_moving_averages

# 需要导入模块: from object_detection import exporter [as 别名]
# 或者: from object_detection.exporter import replace_variable_values_with_moving_averages [as 别名]
def test_replace_variable_values_with_moving_averages(self):
    tmp_dir = self.get_temp_dir()
    trained_checkpoint_prefix = os.path.join(tmp_dir, 'model.ckpt')
    new_checkpoint_prefix = os.path.join(tmp_dir, 'new.ckpt')
    self._save_checkpoint_from_mock_model(trained_checkpoint_prefix,
                                          use_moving_averages=True)
    graph = tf.Graph()
    with graph.as_default():
      fake_model = FakeModel()
      preprocessed_inputs = fake_model.preprocess(
          tf.placeholder(dtype=tf.float32, shape=[None, None, None, 3]))
      predictions = fake_model.predict(preprocessed_inputs)
      fake_model.postprocess(predictions)
      exporter.replace_variable_values_with_moving_averages(
          graph, trained_checkpoint_prefix, new_checkpoint_prefix)

    expected_variables = set(['conv2d/bias', 'conv2d/kernel'])
    variables_in_old_ckpt = self._get_variables_in_checkpoint(
        trained_checkpoint_prefix)
    self.assertIn('conv2d/bias/ExponentialMovingAverage',
                  variables_in_old_ckpt)
    self.assertIn('conv2d/kernel/ExponentialMovingAverage',
                  variables_in_old_ckpt)
    variables_in_new_ckpt = self._get_variables_in_checkpoint(
        new_checkpoint_prefix)
    self.assertTrue(expected_variables.issubset(variables_in_new_ckpt))
    self.assertNotIn('conv2d/bias/ExponentialMovingAverage',
                     variables_in_new_ckpt)
    self.assertNotIn('conv2d/kernel/ExponentialMovingAverage',
                     variables_in_new_ckpt) 
开发者ID:rky0930,项目名称:yolo_v2,代码行数:32,代码来源:exporter_test.py

示例3: test_replace_variable_values_with_moving_averages

# 需要导入模块: from object_detection import exporter [as 别名]
# 或者: from object_detection.exporter import replace_variable_values_with_moving_averages [as 别名]
def test_replace_variable_values_with_moving_averages(self):
        tmp_dir = self.get_temp_dir()
        trained_checkpoint_prefix = os.path.join(tmp_dir, 'model.ckpt')
        new_checkpoint_prefix = os.path.join(tmp_dir, 'new.ckpt')
        self._save_checkpoint_from_mock_model(trained_checkpoint_prefix,
                                              use_moving_averages=True)
        graph = tf.Graph()
        with graph.as_default():
            fake_model = FakeModel()
            preprocessed_inputs, true_image_shapes = fake_model.preprocess(
                tf.placeholder(dtype=tf.float32, shape=[None, None, None, 3]))
            predictions = fake_model.predict(
                preprocessed_inputs, true_image_shapes)
            fake_model.postprocess(predictions, true_image_shapes)
            exporter.replace_variable_values_with_moving_averages(
                graph, trained_checkpoint_prefix, new_checkpoint_prefix)

        expected_variables = set(['conv2d/bias', 'conv2d/kernel'])
        variables_in_old_ckpt = self._get_variables_in_checkpoint(
            trained_checkpoint_prefix)
        self.assertIn('conv2d/bias/ExponentialMovingAverage',
                      variables_in_old_ckpt)
        self.assertIn('conv2d/kernel/ExponentialMovingAverage',
                      variables_in_old_ckpt)
        variables_in_new_ckpt = self._get_variables_in_checkpoint(
            new_checkpoint_prefix)
        self.assertTrue(expected_variables.issubset(variables_in_new_ckpt))
        self.assertNotIn('conv2d/bias/ExponentialMovingAverage',
                         variables_in_new_ckpt)
        self.assertNotIn('conv2d/kernel/ExponentialMovingAverage',
                         variables_in_new_ckpt) 
开发者ID:scorelab,项目名称:Elphas,代码行数:33,代码来源:exporter_test.py


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