title: Tensorflow cost function
body: <p>I have an input dataset x with shape (10,1000), 10 inputs and 1000 lines and a output y with (1,1000), 1 output and 1000 lines.<br></p>
  
  <p>The cost function I defined is </p>
  
  <pre><code>cost = tf.square(Y - prediction, name="cost")
  </code></pre>
  
  <p>The prediction is a single predicted output value and Y is the placeholder of output values. I used the code below to get the value of cost.</p>
  
  <pre><code>cost_value = sess.run(cost, feed_dict ={ X: x, Y : y })
  </code></pre>
  
  <p>Then the output cost function value is a (1000,1000) matrix since the feed of Y is a (1,1000) vector. <br><br>
  The question is how could I make a cost function that calculate the cost in a number instant of a matrix without looping all the inputs line by line.</p>