我正在阅读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')
control_flow_ops.with_dependencies 是什么意思?
请您参考如下方法:
该函数有两个参数 control_flow_ops.with_dependencies(dependencies, output_tensor)。第二个参数 output_tensor,在您的例子中是 total_loss,仅在 dependencies 中的所有操作都被评估之后才被评估。顾名思义,output_tensor 依赖于正确评估的依赖项。此函数强制执行此行为。
Dependencies 是可迭代的操作,在您的例子中是列表中的单个 update_op。
