如果前向兼容性窗口已過期,則返回 true。
用法
tf.compat.forward_compatible(
year, month, day
)
參數
-
year
一年(例如,2018 年)。必須是int
。 -
month
一年中的一個月(1 int 。 -
day
一個月中的一天 (1 int 。
返回
- 如果調用者可以預期生成的序列化 TensorFlow 圖可以在(年、月、日)之後由使用 TensorFlow 庫源代碼編譯的程序使用,則為真。
請參閱版本兼容性。
Forward-compatibility 指的是 TensorFlow 模型(GraphDef 或 SavedModel)的生產者針對比消費者編譯的版本更新的 TensorFlow 庫版本編譯的場景。 "producer" 通常是一個構建和訓練模型的 Python 程序,而 "consumer" 通常是另一個加載和服務模型的程序。
TensorFlow 一直支持從 HEAD 源代碼編譯的程序的 3 周 forward-compatibility 窗口。
例如,考慮創建新操作 MyNewAwesomeAdd
的目的是替換現有 Python 包裝器的實現 - tf.add
的情況。 Python 包裝器實現應從以下內容更改:
def add(inputs, name=None):
return gen_math_ops.add(inputs, name)
到:
from tensorflow.python.compat import compat
def add(inputs, name=None):
if compat.forward_compatible(year, month, day):
# Can use the awesome new implementation.
return gen_math_ops.my_new_awesome_add(inputs, name)
# To maintain forward compatibility, use the old implementation.
return gen_math_ops.add(inputs, name)
其中 year
, month
和 day
指定使用模型的二進製文件預計更新以包含新操作的日期。此日期通常比提交添加新操作的代碼的日期晚至少 3 周。
相關用法
- Python tf.compat.forward_compatibility_horizon用法及代碼示例
- Python tf.compat.v1.distributions.Multinomial.stddev用法及代碼示例
- Python tf.compat.v1.distribute.MirroredStrategy.experimental_distribute_dataset用法及代碼示例
- Python tf.compat.v1.data.TFRecordDataset.interleave用法及代碼示例
- Python tf.compat.v1.distributions.Bernoulli.cross_entropy用法及代碼示例
- Python tf.compat.v1.Variable.eval用法及代碼示例
- Python tf.compat.v1.train.FtrlOptimizer.compute_gradients用法及代碼示例
- Python tf.compat.v1.layers.conv3d用法及代碼示例
- Python tf.compat.v1.strings.length用法及代碼示例
- Python tf.compat.v1.data.Dataset.snapshot用法及代碼示例
- Python tf.compat.v1.data.experimental.SqlDataset.reduce用法及代碼示例
- Python tf.compat.v1.feature_column.categorical_column_with_vocabulary_file用法及代碼示例
- Python tf.compat.v1.data.TextLineDataset.from_tensors用法及代碼示例
- Python tf.compat.v1.variable_scope用法及代碼示例
- Python tf.compat.v1.data.experimental.SqlDataset.as_numpy_iterator用法及代碼示例
- Python tf.compat.v1.distributions.Bernoulli.covariance用法及代碼示例
- Python tf.compat.v1.placeholder用法及代碼示例
- Python tf.compat.v1.layers.Conv3D用法及代碼示例
- Python tf.compat.v1.train.get_or_create_global_step用法及代碼示例
- Python tf.compat.v1.nn.static_rnn用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.compat.forward_compatible。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。