用法
get_concrete_function(
    *args, **kwargs
) -> tf.types.experimental.ConcreteFunction參數
- 
*args投入專攻。
- 
**kwargs投入專攻。
返回
- 
一個ConcreteFunction。
返回專用於輸入類型的 ConcreteFunction。
args 和kwargs 指定的參數遵循正常的函數調用規則。返回的 ConcreteFunction 具有與 self 相同的位置和關鍵字參數集,但它們的類型與 args 和 kwargs 指定的類型兼容(盡管不一定相等)。
@tf.function
def f(x):
  return x
f_concrete = f.get_concrete_function(tf.constant(1.0))
f_concrete = f.get_concrete_function(x=tf.constant(1.0))與普通調用不同,get_concrete_function 允許使用類型說明符而不是 TensorFlow 對象,因此例如 tf.Tensor 可以替換為 tf.TensorSpec 。
@tf.function
def f(x):
  return x
f_concrete = f.get_concrete_function(tf.TensorSpec([], tf.float64))如果函數定義隻允許一種特化,args 和kwargs 可以完全省略。
@tf.function(input_signature=[tf.TensorSpec(None, tf.float32)])
def f(x):
  return x
f_concrete = f.get_concrete_function()返回的ConcreteFunction可以正常調用:
f_concrete(tf.constant(1.0))
<tf.Tensor:shape=(), dtype=float32, numpy=1.0>
f_concrete(x=tf.constant(1.0))
<tf.Tensor:shape=(), dtype=float32, numpy=1.0>相關用法
- Python tf.types.experimental.GenericFunction.experimental_get_compiler_ir用法及代碼示例
- Python tf.types.experimental.TensorLike用法及代碼示例
- Python tf.type_spec_from_value用法及代碼示例
- Python tf.tpu.experimental.embedding.FeatureConfig用法及代碼示例
- Python tf.tpu.experimental.embedding.FTRL用法及代碼示例
- Python tf.tpu.experimental.embedding.TPUEmbedding.apply_gradients用法及代碼示例
- Python tf.train.Coordinator.stop_on_exception用法及代碼示例
- Python tf.tpu.experimental.embedding.TPUEmbedding用法及代碼示例
- Python tf.tpu.experimental.embedding.TPUEmbedding.dequeue用法及代碼示例
- Python tf.train.ExponentialMovingAverage用法及代碼示例
- Python tf.train.Checkpoint.restore用法及代碼示例
- Python tf.test.is_built_with_rocm用法及代碼示例
- Python tf.train.Checkpoint.read用法及代碼示例
- Python tf.test.TestCase.assertLogs用法及代碼示例
- Python tf.test.is_gpu_available用法及代碼示例
- Python tf.test.TestCase.assertItemsEqual用法及代碼示例
- Python tf.train.CheckpointOptions用法及代碼示例
- Python tf.train.list_variables用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.types.experimental.GenericFunction.get_concrete_function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。
