TensorFlow: “Attempting to use uninitialized value” in variable initialization

后端 未结 1 562
谎友^
谎友^ 2020-12-31 03:04

Here\'s my code.

import tensorflow as tf

a=tf.Variable(tf.constant([0,1,2],dtype=tf.int32))
b=tf.Variable(tf.constant([1,1,1],dtype=tf.int32))
recall=tf.met         


        
相关标签:
1条回答
  • 2020-12-31 03:16

    You also need to initialise the local variables hidden in the tf.metrics.recallmethod.

    For example, this piece of code would work:

    init_g = tf.global_variables_initializer()
    init_l = tf.local_variables_initializer()
    with tf.Session() as sess:
        sess.run(init_g)
        sess.run(init_l)
    
    0 讨论(0)
提交回复
热议问题