tf.control_dependencies()和tf.identity()

示例一:
tf.control_dependencies()和tf.identity()
程序运行的结果:
tf.control_dependencies()和tf.identity()
示例二:
tf.control_dependencies()和tf.identity()
运行结果:
tf.control_dependencies()和tf.identity()

仔细观察两个示例的区别,只是第6行代码的不同.
先来说明下第5行:tf.Graph.control_dependencies简单来说就是控制计算顺序。

with g.control_dependencies([a, b, c]):
  # ‘d’ and ‘e’ will only run after ‘a’, ‘b’, and ‘c’ have executed.
  d = …
  e = …


注意一点的是:
tf.control_dependencies()和tf.identity()
第7,8和9行注释后,打印的结果是:
tf.control_dependencies()和tf.identity()
如果注释掉第10行,第7,8或者9行任意一行去掉注意,打印的结果都是数字5,令我迷惑不解的是第9行取消注意打印的结果为什么不是4而是5呢,还没想明白原因,待解惑

非常好的博客地址:
http://blog.****.net/Yan_Joy/article/details/70228401?locationNum=12&fps=1
http://blog.****.net/PKU_Jade/article/details/73498753