How to get the current value of a Variable?

I want to plot my history losses with matplot. But my loss data are returned as Variables from loss function. What’s the way of plotting with PyTorch?

1 Like

You get the value of a Variable using its parameter “data” :

loss = criterion( output, target)
loss_value = loss.data[0] 
5 Likes

Wow thank you, this is so easy. Sorry I was stupid.