`control_flow_ops.with_dependencies` 对 tensoflow 意味着什么?

tid*_*idy 2 python computer-vision deep-learning conv-neural-network tensorflow

我正在阅读tensorflow模型的代码:https : //github.com/tensorflow/models/blob/master/slim/train_image_classifier.py

我对这个代码部分很困惑:

train_tensor = control_flow_ops.with_dependencies([update_op], total_loss,
                                                  name='train_op')
Run Code Online (Sandbox Code Playgroud)

control_flow_ops.with_dependencies 是什么意思?

veg*_*ega 5

该函数有两个参数control_flow_ops.with_dependencies(dependencies, output_tensor)。第二个参数output_tensor,而你的情况是total_loss只计算的所有操作dependencies进行评估。顾名思义,output_tensor依赖于正确评估的依赖项。此函数强制执行此行为。

依赖项是一个可迭代的操作,在您的情况下update_op是列表中的一个。