zoukankan      html  css  js  c++  java
  • 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:	f_jenkinsworkspace
    el-winMwindowsPY35	ensorflowcoreplatformcpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX AVX2
    1.0
  • 相关阅读:
    Demo
    Demo
    Demo
    Demo
    Demo
    【csp模拟赛6】树上统计-启发式合并,线段树合并
    【csp模拟赛6】计数--单调栈
    【csp模拟赛6】相遇--LCA
    【poj1734】Sightseeing trip--无向图最小环
    【poj2709】Painter--贪心
  • 原文地址:https://www.cnblogs.com/weizhen/p/8451476.html
Copyright © 2011-2022 走看看