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


Python tf.inside_function用法及代碼示例

指示調用者代碼是否在 tf.function 內執行。

用法

tf.inside_function()

返回

  • 布爾值,如果調用者代碼在 tf.function 內執行而不是即刻地執行,則為 True。

例子:

tf.inside_function()
False
@tf.function
def f():
  print(tf.inside_function())
f()
True

相關用法


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