用法
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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。