Guest User

Untitled

a guest
Jul 18th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.97 KB | None | 0 0
  1. Step = 1799 | Tensorflow Accuracy = 1.0
  2. Step = 1799 | My Accuracy = 0.0363355780022
  3. Step = 1800 | Tensorflow Accuracy = 1.0
  4. Step = 1800 | My Accuracy = 0.0364694929089
  5. Traceback (most recent call last):
  6. File "CNN-LSTM-seg-reg-sigmoid.py", line 290, in <module>
  7. saver.save(sess, save_path)
  8. File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1085, in save
  9. self.export_meta_graph(meta_graph_filename)
  10. File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/training/saver.py", line 1103, in export_meta_graph
  11. add_shapes=True),
  12. File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2175, in as_graph_def
  13. result, _ = self._as_graph_def(from_version, add_shapes)
  14. File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 2138, in _as_graph_def
  15. raise ValueError("GraphDef cannot be larger than 2GB.")
  16. ValueError: GraphDef cannot be larger than 2GB.
  17.  
  18. # Make prediction
  19. im = Image.open('/home/volcart/Documents/Data/input_crops/temp data0001.tif')
  20. batch_x = np.array(im)
  21. batch_x = batch_x.reshape((1, n_input_x, n_input_y))
  22. batch_x = batch_x.astype(float)
  23. prediction = sess.run(pred, feed_dict={x: batch_x})
  24. prediction = tf.sigmoid(prediction.reshape((n_input_x * n_input_y, n_classes)))
  25. prediction = prediction.eval().reshape((n_input_x, n_input_y, n_classes))
  26.  
  27. # Initializing the variables
  28. init = tf.initialize_all_variables()
  29. saver = tf.train.Saver()
  30.  
  31. gpu_options = tf.GPUOptions()
  32. config = tf.ConfigProto(gpu_options=gpu_options)
  33. config.gpu_options.allow_growth = True
  34.  
  35. # Launch the graph
  36. with tf.Session(config=config) as sess:
  37. sess.run(init)
  38. summary = tf.train.SummaryWriter('/tmp/logdir/', sess.graph) #initialize graph for tensorboard
  39. step = 1
  40. # Import data
  41. data = scroll_data.read_data('/home/volcart/Documents/Data/')
  42. # Keep training until reach max iterations
  43. while step * batch_size < training_iters:
  44. batch_x, batch_y = data.train.next_batch(batch_size)
  45. # Run optimization op (backprop)
  46. batch_x = batch_x.reshape((batch_size, n_input_x, n_input_y))
  47. batch_y = batch_y.reshape((batch_size, n_input_x, n_input_y))
  48. batch_y = convert_to_2_channel(batch_y, batch_size)
  49. sess.run(optimizer, feed_dict={x: batch_x, y: batch_y})
  50. step = step + 1
  51.  
  52. loss, acc = sess.run([cost, accuracy], feed_dict={x: batch_x,
  53. y: batch_y})
  54.  
  55.  
  56. # Make prediction
  57. im = Image.open('/home/volcart/Documents/Data/input_crops/temp data0001.tif')
  58. batch_x = np.array(im)
  59. batch_x = batch_x.reshape((1, n_input_x, n_input_y))
  60. batch_x = batch_x.astype(float)
  61. prediction = sess.run(pred, feed_dict={x: batch_x})
  62. prediction = tf.sigmoid(prediction.reshape((n_input_x * n_input_y, n_classes)))
  63. prediction = prediction.eval().reshape((n_input_x, n_input_y, n_classes))
  64.  
  65. # Temp arrays are to splice the prediction n_input_x x n_input_y x 2
  66. # into 2 matrices n_input_x x n_input_y
  67. temp_arr1 = np.empty((n_input_x, n_input_y))
  68. for i in xrange(n_input_x):
  69. for j in xrange(n_input_x):
  70. for k in xrange(n_classes):
  71. if k == 0:
  72. temp_arr1[i][j] = 1 - prediction[i][j][k]
  73.  
  74. my_acc = accuracy_custom(temp_arr1,batch_y[0,:,:,0])
  75.  
  76. print "Step = " + str(step) + " | Tensorflow Accuracy = " + str(acc)
  77. print "Step = " + str(step) + " | My Accuracy = " + str(my_acc)
  78.  
  79. if step % 100 == 0:
  80. save_path = "/home/volcart/Documents/CNN-LSTM-reg-model/CNN-LSTM-seg-step-" + str(step) + "-model.ckpt"
  81. saver.save(sess, save_path)
  82. csv_file = "/home/volcart/Documents/CNN-LSTM-reg/CNNLSTMreg-step-" + str(step) + "-accuracy-" + str(my_acc) + ".csv"
  83. np.savetxt(csv_file, temp_arr1, delimiter=",")
  84.  
  85. prediction = tf.sigmoid(prediction.reshape((n_input_x * n_input_y, n_classes)))
Add Comment
Please, Sign In to add comment