How to get the list of uninitialized variables from tf.report_uninitialized_variables

后端 未结 1 403
Happy的楠姐
Happy的楠姐 2020-12-12 07:03

The documentation says it\'s a 1 d tensor, however, I have failed to figure out how to access the list.

I would prefer the actual variables rather than names as I wo

相关标签:
1条回答
  • 2020-12-12 07:28

    tf.report_uninitialized_variables() gives you a tensor with the names of the variables. So it will be way more ugly (in my opinion) than my solution here.

    You will need to find all the variables corresponding to names you got from report_uninitialized_variables and they use them in your tf.variables_initializer(). Something like this:

    tf.variables_initializer(
        [v for v in tf.global_variables() if v.name.split(':')[0] in set(sess.run(tf.report_uninitialized_variables()))
    ])
    
    0 讨论(0)
提交回复
热议问题