title: Tensorflow-Keras vector normalise output layer
body: <p>My model outputs a direction vector in 3d space so I do not care about the magnitude of the vector.
  How can I vector normalise the output layer so that the loss function doesn't care about the magnitude either?</p>
  <p>Model:</p>
  <pre class="lang-py prettyprint-override"><code>model = keras.Sequential(
      [
          keras.Input(shape=(17,), dtype=np.float64),
          layers.Dense(9, activation=&quot;relu&quot;),
          layers.Dense(9, activation=&quot;relu&quot;),
          layers.Dense(9, activation=&quot;relu&quot;),
          layers.Dense(9, activation=&quot;relu&quot;),
          layers.Dense(3) # output layer I want to vector normalise
      ]
  )
  </code></pre>
  <p>Alternatively would it be possible to specify for the loss function to only consider the angle between the vectors as loss?</p>
  <p>Thank you.</p>