I have finished re-watching the lesson 13 video and was working through the jupyter notebook “style-transfer.ipynb” discused in last class. I am getting an error towards the end during execution of iterations on optimizer in style transfer
while n_iter <= max_iter: optimizer.step(partial(step,comb_loss))
here is the error:
“RuntimeError: Trying to backward through the graph a second time, but the buffers have already been freed. Specify retain_graph=True when calling backward the first time.”
Has anybody else run into this issue?
looking on google seems to indicate an issue with “backward” method in ~/anaconda3/envs/fastai/lib/python3.6/site-packages/torch/optim/lbfgs.py
"loss.backward() is trying to back-propagate all the way through to the start of time, which works for the first batch but not for the second because the graph for the first batch has been discarded. "
Any pointers on fixing it will be super helpful.