title: Tensorflow 2: Getting Tensor Value
body: <p>I am switching to TF2 and I just followed this <a href="https://www.tensorflow.org/beta/tutorials/quickstart/advanced" rel="nofollow noreferrer">tutorial</a>,
  where the train and step functions are defined now as "@tf.function".</p>
  
  <p>How can I print the values of the Tensors y_pred and loss?</p>
  
  <pre><code>@tf.function
  def train_step(images, labels):
    with tf.GradientTape() as tape:
      predictions = model(images)
      loss = loss_object(labels, predictions)
  
      print("train preds: ", y_pred)
      print("train loss: ", loss)
  
    gradients = tape.gradient(loss, model.trainable_variables)
    optimizer.apply_gradients(zip(gradients, model.trainable_variables))
  
    train_loss(loss)
    train_accuracy(labels, predictions)
  </code></pre>