I tried to extract the feature by adding the VGG16 network to the predicted image and ground truth, and use L1 loss to establish the extracted relationship,
ie, L1_LOSS(VGG16(predicted)-VGG16(ground truth)),

Screenshot from 2018-07-23 17-56-27.png1155×460 63.5 KB

And the following error occurred
Traceback (most recent call last):
**  File “/home/hcj/Desktop/cyc legan collection/0716/PyTorch-CycleGAN-master/train.py”, line 127, in **
**    loss_identity_B_vgg = Criterion_perceptual(val_same_B, val_real_B)* 2.0**
**  File “/home/hcj/.conda/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/module.py”, line 357, in call**
**    result = self.forward(input, kwargs)
**  File “/home/hcj/.conda/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/loss.py”, line 82, in forward*
**    _assert_no_grad(target)**
**  File “/home/hcj/.conda/envs/pytorch/lib/python3.6/site-packages/torch/nn/modules/loss.py”, line 11, in _assert_no_grad**
**    "nn criterions don’t compute the gradient w.r.t. targets - please " **
AssertionError: nn criterions don’t compute the gradient w.r.t. targets - please mark these variables as volatile or not requiring gradients