116、TensorFlow变量的版本
import tensorflow as tf v = tf.get_variable("v", shape=(), initializer=tf.zeros_initializer()) assignment = v.assign_add(1) # Because variables are mutable # it's sometimes useful to know what version of a variable's value is being used # at any point in time. # To force a re-read of the value of a variable after something has happened # you can use tf.Variable.read_value. with tf.control_dependencies([assignment]): w = v.read_value() # w is guaranteed to reflect v's value after the assign_add operation init = tf.global_variables_initializer() with tf.Session() as sess: sess.run(init) print(sess.run(w))
下面是上面输出的结果
2018-02-17 10:57:11.629704: I C:\tf_jenkins\workspace\rel-win\M\windows\PY\35\tensorflow\core\platform\cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2 1.0
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步