Hi my model is not training properly when I added one layer to the pretrained vgg16 model
Here is the code I modified
num_ftrs = model_conv.classifier[6].out_features
model_conv.add_module(“classifier1”,nn.ReLU(inplace=True))
model_conv.classifier1=nn.Sequential(model_conv.classifier1,nn.Dropout(0.5),nn.Linear(num_ftrs,2))
model_conv.classifier.requires_grad=True
print(model_conv)
model_conv = model_conv.to(device)
when I run the code I got RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn to avoid this I added line  loss = Variable(loss, requires_grad=True) to train_model function. Can you please help me?