python - Tensorflow queue is not filled -




i'm sorry still have problems dealing tensorflow , hope here....

i did first solution suggested sraw @ tensorflow not terminate using batches following error now

outofrangeerror (see above traceback): randomshufflequeue '_1_shuffle_batch/random_shuffle_queue' closed , has insufficient elements (requested 30, current size 0)  [[node: shuffle_batch = queuedequeuemanyv2[component_types=[dt_float, dt_float], timeout_ms=-1, _device="/job:localhost/replica:0/task:0/cpu:0"](shuffle_batch/random_shuffle_queue, shuffle_batch/n)]] 

i tried use

try:     while not coord.should_stop():         # run training steps or whatever         sess.run(train_op)  except tf.errors.outofrangeerror: 

but not work well. file dataset.csv existing. can't figure out if there way check if read correctly script.

the hole file looks

from __future__ import print_function  import numpy np import tensorflow tf  urllib.request import urlopen  num_attributes = 15 num_types = 7   def read_from_cvs(filename_queue):     reader = tf.textlinereader()     key, value = reader.read(filename_queue)     record_defaults = [[] col in range((num_attributes+2))]  # no defaults     attributes = tf.decode_csv(value, record_defaults=record_defaults)     features = tf.stack(attributes[1:-1])       #labels = tf.stack(attributes[-1])       labels = tf.one_hot(tf.cast(tf.stack(attributes[-1]), tf.uint8), num_types)     return features, labels  def input_pipeline(filename='dataset.csv', batch_size=30, num_epochs=none):     filename_queue = tf.train.string_input_producer([filename], num_epochs=num_epochs, shuffle=true)     features, labels = read_from_cvs(filename_queue)      min_after_dequeue = batch_size     capacity = min_after_dequeue + 3 * batch_size     feature_batch, label_batch = tf.train.shuffle_batch(         [features, labels], batch_size=batch_size, capacity=capacity,         min_after_dequeue=min_after_dequeue)     return feature_batch, label_batch   def tensorflow():     x, y_ = input_pipeline()      w = tf.variable(tf.zeros([num_attributes, num_types]), name="weights")     b = tf.variable(tf.zeros([num_types]), name="bias")      y = tf.nn.softmax(tf.matmul(x, w) + b)      cross_entropy = tf.reduce_mean(         tf.nn.softmax_cross_entropy_with_logits(labels=y_, logits=y))     train_step = tf.train.gradientdescentoptimizer(0.5).minimize(cross_entropy)      sess = tf.interactivesession()      tf.global_variables_initializer().run()      coord = tf.train.coordinator()     threads = tf.train.start_queue_runners(coord=coord)      _ in range(1200):         sess.run(train_step)     coord.request_stop()     coord.join(threads)      #correct_prediction = tf.equal(tf.argmax(y, 1), tf.argmax(y_, 1))     #accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))     #print(sess.run(accuracy, ))      sess.close()  def main():     tensorflow()   if __name__ == '__main__':     main() 

i hope someout provide help.

edit: figured out problem csv file contained format failure.





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -