0

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 would like to initialize them via tf.variables_initializer()

Paul O
  • 425
  • 5
  • 19
  • Do you need to figure out how to use this function or do you actually need to initialize uninitialized vars? – Salvador Dali May 30 '17 at 23:35
  • @SalvadorDali I saw and commented on you answer to https://stackoverflow.com/questions/35164529/in-tensorflow-is-there-any-way-to-just-initialize-uninitialised-variables and was trying to figure out if I could get the actual variables from it or just the names. – Paul O May 30 '17 at 23:43
  • Understood, so you just want to find out how to use this function. Will try to answer it later. – Salvador Dali May 30 '17 at 23:49

1 Answers1

8

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()))
])
Salvador Dali
  • 214,103
  • 147
  • 703
  • 753