當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python tf.compat.forward_compatibility_horizon用法及代碼示例

用於測試生成圖的前向兼容性的上下文管理器。

用法

@tf_contextlib.contextmanager
tf.compat.forward_compatibility_horizon(
    year, month, day
)

參數

  • year 一年(例如,2018 年)。必須是 int
  • month 一年中的一個月(1 int 。
  • day 一個月中的一天 (1 int 。

生成(Yield)

  • 無。

請參閱版本兼容性。

為確保生成的圖形(參見 forward_compatible )與舊二進製文件的前向兼容性,可以通過以下方式控製新函數:

if compat.forward_compatible(year=2018, month=08, date=01):
  generate_graph_with_new_features()
else:
  generate_graph_so_older_binaries_can_consume_it()

但是,在添加新函數時,可能希望在前向兼容性窗口到期之前對其進行單元測試。此上下文管理器啟用此類測試。例如:

from tensorflow.python.compat import compat

def testMyNewFeature(self):
  with compat.forward_compatibility_horizon(2018, 08, 02):
     # Test that generate_graph_with_new_features() has an effect

相關用法


注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.compat.forward_compatibility_horizon。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。