Thank you! I’m not sure about that. What I did in init() of my net class shows as following:

Loading vgg pre-trained model with:

vgg_pretrained_features = models.vgg19(pretrained=True).features


Defining  my net in nn.Sequential() where different from origin vgg in using "nn.ReflectionPad((1,1,1,1)) "and “nn.Conv2d(in_channels, out_channels, 3, 1, 0)” instead of “nn.Conv2d(in_channels, out_channels, 3, 1, 1)”. Meanwhile, changing the nn.MaxPool2d(2,2) to nn.MaxPool2d(2,2,return_indices=True).
Loading the conv layers weights and biases to my net with:
nn.Sequential[1].weight.copy_(vgg_pretrained_features[0].weight) nn.Sequential[1].bias.copy_(vgg_pretrained_features[0].bias)

freezing the grad refer to examples/fast_neural_style 10


So far, I don’t the no_grad() to forbid computing the grad.