TensorFlow-Book icon indicating copy to clipboard operation
TensorFlow-Book copied to clipboard

Issue found on chapter 5 (clustering)

Open rezacsedu opened this issue 7 years ago • 2 comments

When I executed, the audio_clustering.py script, I got the following error:

FailedPreconditionError (see above for traceback): Attempting to use uninitialized value matching_filenames [[Node: matching_filenames/read = IdentityT=DT_STRING, _class=["loc:@matching_filenames"], _device="/job:localhost/replica:0/task:0/cpu:0"]]

To solve this, I had to make the following changes:

  1. I had to initialize the local variables using tf.local_variables_initializer()
  2. Then I had to install/downgrade to numpy 1.11.0 using sudo pip install -U numpy==1.11.0

Maybe you can keep this note in your codes as well.

rezacsedu avatar May 10 '17 17:05 rezacsedu

I solve the error by your comment,thank you.

benjaminxz avatar Jun 26 '17 05:06 benjaminxz

no need to downgrade numpy. The code looks like: ` import tensorflow as tf #Обход директории для просмотра данных import os

path=r'./audio_dataset/' os.chdir(path) print(os.getcwd())

filenames = tf.train.match_filenames_once('*.wav') count_num_files = tf.size(filenames) #print(count_num_files) filename_queue = tf.train.string_input_producer(filenames) init = (tf.global_variables_initializer(), tf.local_variables_initializer())

reader = tf.WholeFileReader() # По умолчанию считывает файл из библиотеки Tensorflow filename, file_contents = reader.read(filename_queue) #Выполняет операцию считывания with tf.Session() as sess: sess.run(init) num_files = sess.run (count_num_files) # Подсчитывает число файлов #print(num_files) coord = tf.train.Coordinator() # Инициализирует потоки threads = tf.train.start_queue_runners(coord=coord) for i in range(num_files): audio_file = sess.run(filename) print(audio_file) `

zoldaten avatar Mar 30 '21 07:03 zoldaten