title: Access loss metric from keras model
body: <p>I am trying to access the training loss of my model which I have built, as I call a training loop on it. I have built a model as follows:</p>
  <pre><code>    def create_model(self):
          
          model = Sequential()
          model.add(Dense(172, input_shape=(1, 172), activation = 'relu'))
          model.add(Dense(172, activation = 'relu'))
          model.add(Dense(86, activation = 'relu'))
          model.add(Dense(43, activation = 'relu'))
          model.add(Dense(21, activation = &quot;relu&quot;))
          model.add(Flatten())
          model.add(Dense(7, activation=&quot;linear&quot;))
          model.compile(loss=&quot;mse&quot;, optimizer=Adam(lr=0.001), metrics=['accuracy'])
          return model
  
  </code></pre>
  <p>And my fit is as follows:</p>
  <pre><code>self.model.fit(np.array(X), np.array(y), batch_size=MINIBATCH_SIZE, verbose=0, shuffle=False) 
  </code></pre>
  <p>The model is fit on a batch, and is part of a larger class (DQN Agent).</p>
  <p>As I run a fit every timestep, and I have multiple timesteps per episode, how can I have a variable I can access in the training loop which gives me the loss of the network, so I can monitor it more closely? (with an end goal of adding it to tensorboard)</p>
  <p>I can try to either access this every step or every episode (300 steps), whatever works easier.</p>