title: Model.get_weights in custom loss function TF 2.0
body: <p>I am designing a custom loss function in which i need to access model weights in the loss function.</p>
  <p>Code:</p>
  <pre><code>def my_loss(y_true, y_pred):
      model.get_weights()
      return K.sum(-(y_true * K.log(y_pred)))/batch_size + ((error2/num_conv)*scal_f)
  </code></pre>
  <p>But when I try to access weights in loss function by calling get_weights() it gives me following error</p>
  <blockquote>
  <p>Error = &quot;Cannot get value inside Tensorflow graph function.&quot;</p>
  </blockquote>