I have following code for reading files names from directory:
directory = "C:/pics/*.csv"
file_names=tf.train.match_filenames_once(directory)
print(file_names)
<tf.Variable 'matching_filenames_1:0' shape=<unknown> dtype=string_ref>
with tf.Session() as sess:
tf.global_variables_initializer().run()
print(sess.run(file_names))
When I run session I am getting the following error: " Attempting to use uninitialized value matching_filenames"
Please tell me what I am doing wrong.
There is a subtle distinction between what TF considers global and local variables. This code works as you expect
import tensorflow as tf directory = "*.*" file_names = tf.train.match_filenames_once(directory) init = (tf.global_variables_initializer(), tf.local_variables_initializer()) with tf.Session() as sess: sess.run(init) print(sess.run(file_names))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With