以字符串形式返回 AutoGraph 生成的源代碼。
用法
tf.compat.v1.autograph.to_code(
entity, recursive=True, arg_values=None, arg_types=None, indentation='
', experimental_optional_features=None
)
參數
-
entity
Python 可調用或類。 -
recursive
是否遞歸轉換轉換後的函數可能調用的任何函數。 -
arg_values
已棄用。 -
arg_types
已棄用。 -
indentation
已棄用。 -
experimental_optional_features
None
,一個元組或單個tf.autograph.experimental.Feature
值。
返回
- 轉換後的代碼為字符串。
示例用法:
def f(x):
if x < 0:
x = -x
return x
tf.autograph.to_code(f)
"...def tf__f(x):..."
另請參閱:tf.autograph.to_graph
。
注意:如果函數已用 tf.function
修飾,則傳遞其底層 Python 函數,而不是 `tf.function 創建的可調用函數:
@tf.function
def f(x):
if x < 0:
x = -x
return x
tf.autograph.to_code(f.python_function)
"...def tf__f(x):..."
相關用法
- Python tf.compat.v1.autograph.to_graph用法及代碼示例
- Python tf.compat.v1.assert_none_equal用法及代碼示例
- Python tf.compat.v1.assign_add用法及代碼示例
- Python tf.compat.v1.assert_near用法及代碼示例
- Python tf.compat.v1.assert_negative用法及代碼示例
- Python tf.compat.v1.assert_less_equal用法及代碼示例
- Python tf.compat.v1.arg_max用法及代碼示例
- Python tf.compat.v1.arg_min用法及代碼示例
- Python tf.compat.v1.assign用法及代碼示例
- Python tf.compat.v1.assign_sub用法及代碼示例
- Python tf.compat.v1.argmin用法及代碼示例
- Python tf.compat.v1.assert_non_positive用法及代碼示例
- Python tf.compat.v1.argmax用法及代碼示例
- Python tf.compat.v1.assert_integer用法及代碼示例
- Python tf.compat.v1.assert_greater用法及代碼示例
- Python tf.compat.v1.assert_non_negative用法及代碼示例
- Python tf.compat.v1.assert_rank_at_least用法及代碼示例
- Python tf.compat.v1.assert_less用法及代碼示例
- Python tf.compat.v1.assert_rank_in用法及代碼示例
- Python tf.compat.v1.assert_greater_equal用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.compat.v1.autograph.to_code。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。