TypeError: 'LBFGS' object is not iterable

So I setup my input image:

image = Image.open(image_name)
image = image.convert('RGB')
loader = transforms.Compose([transforms.Resize((image_size)), transforms.ToTensor()])  # resize and convert to tensor
image = Variable(loader(image))
image = image.unsqueeze(0)
img = input_image.clone()
img = nn.Parameter(img.data,requires_grad=True)

And then I try to run LBFGS:

x, losses = optim.LBFGS([img])

And I get this error:

 x, losses = optim.LBFGS([img])
TypeError: 'LBFGS' object is not iterable

I have a feval function, and I tried to create a dictionary for my input parameters:

  optim_state = {
    "max_iter": 1000,
    "tolerance_change": -1,
    "tolerance_grad": -1,

This worked in torch.legacy.optim:

x, losses = optim.LBFGS(feval, img, optim_state)

But that results in this error with torch.optim:

  File "/usr/local/lib/python2.7/dist-packages/torch/optim/lbfgs.py", line 39, in __init__
    max_eval = max_iter * 5 // 4
TypeError: unsupported operand type(s) for *: 'dict' and 'int'

What am I doing wrong here?

So unlike the legacy modules, I don’t think I can make a feval function which I input into the optimizer. Instead I have to do it like this:

optimizer = optim.LBFGS([img], optim_state)

And then I input the feval function via optimizer.step inside of loop: