title: Tensorflow: can I define a weighted mean squared error loss function?
body: <p>I've got a data set with the following shape:</p>
  
  <pre><code>x1   x2   x3   w   y
  1    2    5    3   4
  4    6    6    1   2
  5    2    7    3   1
  1    6    8    1   8
  ...
  </code></pre>
  
  <p>I would like to predict <code>y</code> from <code>x1</code>, <code>x2</code> and <code>x3</code>, with the following loss function (example in Pyhton):</p>
  
  <pre><code>loss = numpy.dot(w, (y-y_pred)**2)
  </code></pre>
  
  <p>Is it possible to train a model with this loss function in Tensorflow (or Keras)?</p>
  
  <p>The model must use only <code>x1</code>, <code>x2</code> and <code>x3</code> to predict <code>y</code>, while <code>w</code> is unknown during inference.</p>