In lesson-2 SGD, I’m unable to plot the final graph. It throws the below error
What is wrong here?
Thanks,
S.Ajaykumaar
In lesson-2 SGD, I’m unable to plot the final graph. It throws the below error
Thanks,
S.Ajaykumaar
At the animate part, changing a to a.detach() works for me.
Thanks. That works. I’ve been googling around but still not sure what it does. Could you explain what .detach() does? or is this something that is covered in great detail in part 2?
I found a good discussion thread in the PyTorch forum on this issue. As I understand it, since numpy cannot handle gradients/backpropagation and processes on the cpu, a tensor that requires_grad_()
has to be detached from the gradients, and explicitly moved to the .cpu()
where numpy can work with it.
the fastai method to_np
does something similar, but instead of detach()
it pulls the data
from the tensor onto the cpu
before converting it to a numpy array.