machine learning - Tensorflow RNN stuck at high cost -


the following rnn model decreases loss first 1 or 2 epochs , fluctuates around cost of 6. seems model random , not learning @ all. varied learning rate 0.1 0.0001 , didn't help. data fed input pipeline, worked fine other models, functions extract label , images not presented here. have looked @ many times still couldn't find what's wrong it. here's code:

n_steps = 224 n_inputs = 224 learning_rate = 0.00015 batch_size = 256 # n_neurons epochs = 100 num_batch = int(len(trainnames)/batch_size) keep_prob = tf.placeholder(tf.float32)  # train queue train_queue = tf.randomshufflequeue(len(trainnames)*1.5, 0, [tf.string, tf.float32], shapes=[[],[num_labels,]])  enqueue_train = train_queue.enqueue_many([trainnames, train_label])  train_image, train_image_label = train_queue.dequeue()  train_image = read_image_file(train_image)  train_batch, train_label_batch = tf.train.batch(     [train_image, train_image_label],     batch_size=batch_size,     num_threads=1,     capacity=10*batch_size,     enqueue_many=false,     shapes=[[224,224], [num_labels,]],     allow_smaller_final_batch=true )  train_close = train_queue.close()    def rnn(inputs, reuse):     tf.variable_scope('cells', reuse=reuse):         basic_cell = tf.contrib.rnn.basicrnncell(num_units=batch_size, reuse=reuse)      tf.variable_scope('rnn'):         outputs, states = tf.nn.dynamic_rnn(basic_cell, inputs, dtype=tf.float32)      fc_drop = tf.nn.dropout(states, keep_prob)      logits = tf.contrib.layers.fully_connected(fc_drop, num_labels, activation_fn=none)      return logits  #training tf.name_scope("cost_function") scope:     cost = tf.reduce_mean(tf.nn.softmax_cross_entropy_with_logits(labels=train_label_batch, logits=rnn(train_batch, reuse=none)))     train_step = tf.train.momentumoptimizer(learning_rate, 0.9).minimize(cost)   cost_summary = tf.summary.scalar("cost_function", cost) file_writer = tf.summary.filewriter(logdir)  #session tf.session() sess:     sess.run(tf.local_variables_initializer())     sess.run(tf.global_variables_initializer())     coord = tf.train.coordinator()     threads = tf.train.start_queue_runners(sess=sess, coord=coord, start=true)      step = 0     epoch in range(epochs):         sess.run(enqueue_train)         batch in range(num_batch):             if step % 100 == 0:                 summary_str = cost_summary.eval(feed_dict={keep_prob: 1.0})                 file_writer.add_summary(summary_str, step)             else:                 sess.run(train_step, feed_dict={keep_prob: 0.5})             step += 1     sess.run(train_close)      coord.request_stop()     coord.join(threads)      file_writer.close() 


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -