當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。