title: "Cannot convert a ndarray into a Tensor or Operation." error when trying to fetch a value from session.run in tensorflow
body: <p>I have created a siamese network in tensorflow. I am calculating the distance between two tensors using the below code:</p>
  
  <pre><code>distance = tf.sqrt(tf.reduce_sum(tf.square(tf.subtract(question1_predictions, question2_predictions)), reduction_indices=1))
  </code></pre>
  
  <p>I am able to train the model without any errors. In the inference section, I am retrieving the <code>distance</code> tensor as below:</p>
  
  <pre><code>test_state, distance = sess.run([question1_final_state, distance], feed_dict=feed)
  </code></pre>
  
  <p>Tensorflow is throwing an error:</p>
  
  <blockquote>
    <p>Fetch argument array([....], dtype=float32) has invalid type , must be a string or Tensor. (Can not convert a
    ndarray into a Tensor or Operation.)</p>
  </blockquote>
  
  <p>When I print the <code>distance</code> tensor, before and after the <code>session.run</code> in the training section, it shows as <code>&lt;class 'tensorflow.python.framework.ops.Tensor'&gt;</code>. So the replacement of tensor <code>distance</code> with numpy <code>distance</code> is happening in the <code>session.run</code> of inference section. Following the code from the inference section:</p>
  
  <pre><code>with graph.as_default():
      saver = tf.train.Saver()
  
  with tf.Session(graph=graph) as sess:
      sess.run(tf.global_variables_initializer(), feed_dict={embedding_placeholder: embedding_matrix})
      saver.restore(sess, tf.train.latest_checkpoint('checkpoints'))
  
      test_state = sess.run(initial_state)
  
      for ii, (x1, x2, batch_test_ids) in enumerate(get_test_batches(test_question1_features, test_question2_features, test_ids, batch_size), 1):
          feed = {question1_inputs: x1,
                  question2_inputs: x2,
                  keep_prob: 1,
                  initial_state: test_state
                 }
          test_state, distance = sess.run([question1_final_state, distance], feed_dict=feed)
  </code></pre>