How to plot Loss curves and print loss values in CGANs

Hi All,

By using TensorFlow pix2pix code block I want to print and plot the loss curve but while printing the loss Instead of direct values I am getting as below screenshot. Kindly please help me with how to print the loss values and how to plot the loss curve.


Hi @manikanthp,

As I understand, it seems you’re printing the losses inside the @tf.function which runs in graph mode and causes them to appear as tensors. To print and plot in this case, I suggest to return the losses from the train_step function, store them and then handle the printing and plot outside of the @tf.function. I’ve included a sample code printing and plotting loss in tf.function for your reference.

Also, you can use tf.print to print values in graph mode.

Thank You.