原文参考:
http://blog.csdn.net/u012436149/article/details/72084744
Args: control_inputs: A list of Operation or Tensor objects which must be executed or computed before running the operations defined in the context. Can also be None to clear the control dependencies.
ARGS:
control_inputs:在运行上下文中定义的操作之前必须执行或计算的 Operation 列表或 Tensor 对象。也可以是不清除控件依赖项。
Returns: A context manager that specifies control dependencies for all operations constructed within the context.
返回:
指定上下文中构建的所有操作的控制依赖关系的上下文管理器。
例子:
opt = tf.train.Optimizer().minize(loss)
with tf.control_dependencies([opt]):
updated_weight = tf.identity(weight)
with tf.Session() as sess:
tf.global_variables_initializer().run()
sess.run(updated_weight, feed_dict={...}) # 这样每次得到的都是更新后的weight