I am trying to create a generative network based on the pre-trained Inception_v3.

I fix all the weights in the model
create a Variable whose size is (2, 3, 299, 299)
create targets of size (2, 1000) that I want my final layer activations to become as close as possible to by optimizing the Variable.

And it gives me the error: «RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation».
This is strange, because if I do the same thing with VGG16, everything works:
# minimalist code with Inception_v3 that should work but throws the error:

import torch
from torch.autograd import Variable
import torch.optim as optim
import torch.nn as nn
import torchvision

torch.set_default_tensor_type('torch.FloatTensor')
Iv3 = torchvision.models.inception_v3(pretrained=True)
for i in Iv3.parameters():
    i.requires_grad = False

criterion = nn.CrossEntropyLoss()
x = Variable(torch.randn(2, 3, 299, 299), requires_grad=True)
target = torch.empty(2, dtype=torch.long).random_(1000)
output = Iv3(x)
loss = criterion(output[0], target)
loss.backward()
print(x.grad)

# ########the same code but with VGG16 works ##########################

import torch
from torch.autograd import Variable
import torch.optim as optim
import torch.nn as nn
import torchvision

torch.set_default_tensor_type('torch.FloatTensor')
vgg16 = torchvision.models.vgg16(pretrained=True)
for i in vgg16.parameters():
    i.requires_grad = False

criterion = nn.CrossEntropyLoss()
x = Variable(torch.randn(2, 3, 229, 229), requires_grad=True)
target = torch.empty(2, dtype=torch.long).random_(1000)
output = vgg16(x)
loss = criterion(output, target)
loss.backward()
print(x.grad)

Please help.