用法
execute(
fn, exclusive_resource_access=True, name=None
)
參數
-
fn
要執行的函數。必須返回至少一個張量。 -
exclusive_resource_access
fn
所需的資源是否應該是這個CriticalSection
獨有的。默認值:True
。如果您將在兩個不同的 CriticalSection 中以隻讀模式訪問資源,您可能希望將其設置為False
。 -
name
創建執行操作時使用的名稱。
返回
-
從
fn()
返回的張量。
拋出
-
ValueError
如果fn
嘗試以任何可能導致死鎖的嵌套或惰性方式鎖定此CriticalSection
。 -
ValueError
如果exclusive_resource_access == True
和另一個CriticalSection
執行請求與fn
相同的資源。請注意,即使exclusive_resource_access
是True
,如果在沒有exclusive_resource_access=True
的情況下創建了另一個CriticalSection
中的另一個執行,則會引發ValueError
。
在臨界區執行函數fn()
。
fn
不應接受任何參數。要在臨界區調用 fn
時添加額外的參數,請創建一個 lambda:
critical_section.execute(lambda:fn(*my_args, **my_kwargs))
相關用法
- Python tf.CriticalSection用法及代碼示例
- 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.summary.scalar用法及代碼示例
- Python tf.linalg.LinearOperatorFullMatrix.matvec用法及代碼示例
- Python tf.linalg.LinearOperatorToeplitz.solve用法及代碼示例
- Python tf.raw_ops.TPUReplicatedInput用法及代碼示例
- Python tf.raw_ops.Bitcast用法及代碼示例
- Python tf.compat.v1.distributions.Bernoulli.cross_entropy用法及代碼示例
- Python tf.compat.v1.Variable.eval用法及代碼示例
- Python tf.compat.v1.train.FtrlOptimizer.compute_gradients用法及代碼示例
- Python tf.distribute.OneDeviceStrategy.experimental_distribute_values_from_function用法及代碼示例
- Python tf.math.special.fresnel_cos用法及代碼示例
- Python tf.keras.applications.inception_resnet_v2.preprocess_input用法及代碼示例
- Python tf.compat.v1.layers.conv3d用法及代碼示例
- Python tf.Variable.__lt__用法及代碼示例
- Python tf.keras.metrics.Mean.merge_state用法及代碼示例
- Python tf.keras.layers.InputLayer用法及代碼示例
- Python tf.compat.v1.strings.length用法及代碼示例
注:本文由純淨天空篩選整理自tensorflow.org大神的英文原創作品 tf.CriticalSection.execute。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。