title: How to extract the output of tensorflow model?
body: <p>I've been trying to train a model as usual with train/test data. I was able to have my accuracy, cost + the valid accuracy and cost. So I presume that the model is working and the result is enough with an 85%.</p>
  <p>Now, after I finished with my train/test data, I have a csv file with the same type and structure of data but without one column (default -indicate if client will pay or be delayed). I'm trying to predict this value with the model. I'm bugging on how to insert those data and get back with the missing column.</p>
  <h1>Problem section :</h1>
  <p>This is my code for restoring and predict on the new data -&gt; (y_pred [5100x41])</p>
  <pre><code>with tf.Session() as sess:
      saver = tf.train.import_meta_graph('my_test_model101.meta')
      print(&quot;Model found.&quot;)
  
      saver.restore(sess, tf.train.latest_checkpoint('./'))
      print(&quot;Model restored compl.&quot;)
  
      z = tf.placeholder(tf.float32, shape= (None,5100))
  
      y_pred= y_pred.as_matrix()
  
      output =sess.run(z,feed_dict={x: y_pred})
      print(output)
  </code></pre>
  <p>Can anyone help me to understand what's I am doing wrong here ?!!!</p>
  <h1>Error message is:</h1>
  <pre><code>InvalidArgumentError (see above for traceback): You must feed a value for placeholder tensor 'Placeholder_4' with dtype float and shape [?,5100]
       [[Node: Placeholder_4 = Placeholder[dtype=DT_FLOAT, shape=[?,5100], _device=&quot;/job:localhost/replica:0/task:0/device:CPU:0&quot;]()]]
  </code></pre>
  <h1>Expecting:</h1>
  <p>My input [5100 x 41] but the last column had initially Nan value, I want it with the predicted value which is supposed to be 0 or 1.</p>
  <h2>To see the trained model architecure :</h2>
  <h1>Model architecture :</h1>
  <pre><code># Number of input nodes.
  input_nodes = 41
  
  # Multiplier maintains a fixed ratio of nodes between each layer.
  mulitplier = 3
  
  # Number of nodes in each hidden layer
  hidden_nodes1 = 41
  hidden_nodes2 = round(hidden_nodes1 * mulitplier)
  hidden_nodes3 = round(hidden_nodes2 * mulitplier)
  
  # Percent of nodes to keep during dropout.
  pkeep = tf.placeholder(tf.float32)
  
  # input
  x = tf.placeholder(tf.float32, [None, input_nodes])
  
  # layer 1
  W1 = tf.Variable(tf.truncated_normal([input_nodes, hidden_nodes1], stddev = 0.15))
  b1 = tf.Variable(tf.zeros([hidden_nodes1]))
  y1 = tf.nn.sigmoid(tf.matmul(x, W1) + b1)
  
  # layer 2
  W2 = tf.Variable(tf.truncated_normal([hidden_nodes1, hidden_nodes2], stddev = 0.15))
  b2 = tf.Variable(tf.zeros([hidden_nodes2]))
  y2 = tf.nn.sigmoid(tf.matmul(y1, W2) + b2)
  
  # layer 3
  W3 = tf.Variable(tf.truncated_normal([hidden_nodes2, hidden_nodes3], stddev = 0.15))
  b3 = tf.Variable(tf.zeros([hidden_nodes3]))
  y3 = tf.nn.sigmoid(tf.matmul(y2, W3) + b3)
  y3 = tf.nn.dropout(y3, pkeep)
  
  # layer 4
  W4 = tf.Variable(tf.truncated_normal([hidden_nodes3, 2], stddev = 0.15))
  b4 = tf.Variable(tf.zeros([2]))
  y4 = tf.nn.softmax(tf.matmul(y3, W4) + b4)
  
  # output
  y = y4
  y_ = tf.placeholder(tf.float32, [None, 2])
  </code></pre>
  <p>After building the model, I understand you need to add Placeholder to stock what you're looking for. So :</p>
  <pre><code># Parameters
  training_epochs = 5 # These proved to be enough to let the network learn
  training_dropout = 0.9
  display_step = 1 # 10
  n_samples = y_train.shape[0]
  batch_size = 2048
  learning_rate = 0.001
  
  # Cost function: Cross Entropy
  cost = -tf.reduce_sum(y_ * tf.log(y))
  
  # We will optimize our model via AdamOptimizer
  optimizer = tf.train.AdamOptimizer(learning_rate).minimize(cost)
  
  # Correct prediction if the most likely value (default or non Default) from softmax equals the target value.
  correct_prediction = tf.equal(tf.argmax(y,1), tf.argmax(y_,1))
  accuracy = tf.reduce_mean(tf.cast(correct_prediction, tf.float32))
  </code></pre>
  <p>Till now everything is working well and I saved the model. I was able to restore this model (printed the variables and all was there---So restore is fine)</p>