Guest User

Untitled

a guest
Jan 23rd, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1. input_dir = "parallel_win_10_40_conv_3l_rnn"
  2. input_file = "parallel_win_10_40_conv_3l_rnn"
  3. saver = tf.train.import_meta_graph("./result/cnn_rnn_parallel/tune_rnn_layer/"+input_dir+"/model_"+input_file+".meta")
  4.  
  5. # # Method 1
  6. # all_placeholders = [x for x in tf.get_default_graph().get_operations() if x.type == "Placeholder"]
  7. # cnn_in, rnn_in, Y = all_placeholders[0], all_placeholders[1], all_placeholders[2]
  8. # keep_prob, phase_train = all_placeholders[3], all_placeholders[4]
  9.  
  10. # Method 2
  11. cnn_in = tf.placeholder(tf.float32, shape=[None, input_height, input_width, input_channel_num], name='cnn_in')
  12. rnn_in = tf.placeholder(tf.float32, shape=[None, n_time_step, n_input_ele], name='rnn_in')
  13. Y = tf.placeholder(tf.float32, shape=[None, n_labels], name = 'Y')
  14. keep_prob = tf.placeholder(tf.float32, name='keep_prob')
  15. phase_train = tf.placeholder(tf.bool, name='phase_train')
  16.  
  17. with tf.Session() as session:
  18. saver.restore(session, "./result/cnn_rnn_parallel/tune_rnn_layer/"+input_dir+"/model_"+input_file)
  19.  
  20. test_cnn_batch = np.zeros(shape=[accuracy_batch_size], dtype=float)
  21. test_rnn_batch = np.zeros(shape=[accuracy_batch_size], dtype=float)
  22.  
  23. offset = (accuracy_batch_size) % (test_y.shape[0] - accuracy_batch_size)
  24. test_cnn_batch = cnn_test_x[offset:(offset + accuracy_batch_size), :, :, :, :]
  25. test_cnn_batch = test_cnn_batch.reshape(len(test_cnn_batch) * window_size, input_height, input_width, 1)
  26. test_rnn_batch = rnn_test_x[offset:(offset + accuracy_batch_size), :, :]
  27. test_batch_y = test_y[offset:(offset + accuracy_batch_size), :]
  28.  
  29. print(session.run('fin_m:0', feed_dict={cnn_in: test_cnn_batch, rnn_in: test_rnn_batch,
  30. Y: test_batch_y, keep_prob: 1.0, phase_train: False}))
Add Comment
Please, Sign In to add comment