Q:

Why does this TensorFlow snippet throw an error in feeding?

Code
#!/usr/bin/env python3
import tensorflow as tf
import numpy as np

def customOps(n):
  x = tf.placeholder(tf.float32)
  v1 = tf.reduce_sum(x,1)
  v2 = tf.reduce_sum(x,0)
  v = tf.nn.softmax(tf.concat([v1, v2], 0))
  index = np.argmax(v)
  if index > n/3:
    finalval = tf.norm(v1-v2, ord='euclidean')
  else:
    finalval = tf.norm(v1+v2, ord='euclidean')
  return finalval

if __name__ == '__main__':
  mat = np.asarray([[0, 1], [1, 0]], dtype = np.float32)
  n = mat.shape[0]

  finalVal = customOps(n)

  init = tf.global_variables_initializer()
  sess = tf.Session()
  sess.run(init)
  outVal = sess.run(finalVal, feed_dict={x:mat})
  print(outVal)
  sess.close()

Error Thrown
InvalidArgumentError: You must feed a value for placeholder tensor 'Placeholder_5' with dtype float [[{{node Placeholder_5}} = Placeholder[dtype=DT_FLOAT, shape=<unknown>, _device="/job:localhost/replica:0/task:0/device:CPU:0"]()]]

The error is thrown at sess.run(init) line in the above snippet. I am feeding a float type array through feed_dict and I am not sure why the error is being thrown.
Where is the error and why?

A:

Why the error:
Because you ran the same snippet multiple times in an unclean graph (i.e, your graph has multiple copies of the network).
The reason I can say this is the _5 at the end of the node name in the error message. TF assigns a default name to all tensors in the graph using incremental indices in case a name is already taken. Placeholder_5 means that in the same graph there is at least 5 Placeholder instances without a custom default name assigned which, given your code, should be impossible unless you called the function multiple times without cleaning up the graph.
How to fix it:
Run in a clean graph: Put tf.reset_default_graph() before finalVal = customOps(n).
Note: Your code has more issues than that (for example, you have x in the main branch, but x is a local variable of customOps), but the cause of the error you have is the one stated above.
Below you find a tested and working version of your code that addresses both issues.
import tensorflow as tf
import numpy as np

def customOps(n):
  x = tf.placeholder(tf.float32)
  v1 = tf.reduce_sum(x,1)
  v2 = tf.reduce_sum(x,0)
  v = tf.nn.softmax(tf.concat([v1, v2], 0))
  index = np.argmax(v)
  if index > n/3:
    finalval = tf.norm(v1-v2, ord='euclidean')
  else:
    finalval = tf.norm(v1+v2, ord='euclidean')
  return x, finalval

if __name__ == '__main__':
  mat = np.asarray([[0, 1], [1, 0]], dtype = np.float32)
  n = mat.shape[0]

  tf.reset_default_graph()
  x, finalVal = customOps(n)

  init = tf.global_variables_initializer()
  sess = tf.Session()
  sess.run(init)
  outVal = sess.run(finalVal, feed_dict={x:mat})
  print(outVal)
  sess.close()

