LBFGS throws RuntimeError

Hello, everyone.

I’m trying to run NeuralStyleTransfer tutorial from Neural Transfer Using PyTorch — PyTorch Tutorials 1.9.0+cu102 documentation
My torch version is 1.9.0

run_style_transfer function throws next error: RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.
Traceback shows, It is happening inside the lbfgs optimizer (in _gather_flat_grad function)
Is there any way to handle this error without changing optimizer itself? Plus, can anyone explain, why this error occurs?
Thank in advance

Got it. You should do input_img = content_img.clone().contiguous() to make it work

1 Like