Open PangzeCheung opened 3 years ago
I found that the layers of vgg you used in the style loss and content loss are different. x_vgg, y_vgg = self.vgg(x), self.vgg(y)
content_loss = 0.0 content_loss += self.weights[0] self.criterion(x_vgg['relu1_1'], y_vgg['relu1_1']) content_loss += self.weights[1] self.criterion(x_vgg['relu2_1'], y_vgg['relu2_1']) content_loss += self.weights[2] self.criterion(x_vgg['relu3_1'], y_vgg['relu3_1']) content_loss += self.weights[3] self.criterion(x_vgg['relu4_1'], y_vgg['relu4_1']) content_loss += self.weights[4] * self.criterion(x_vgg['relu5_1'], y_vgg['relu5_1'])
style_loss = 0.0 style_loss += self.criterion(self.compute_gram(x_vgg['relu2_2']), self.compute_gram(y_vgg['relu2_2'])) style_loss += self.criterion(self.compute_gram(x_vgg['relu3_4']), self.compute_gram(y_vgg['relu3_4'])) style_loss += self.criterion(self.compute_gram(x_vgg['relu4_4']), self.compute_gram(y_vgg['relu4_4'])) style_loss += self.criterion(self.compute_gram(x_vgg['relu5_2']), self.compute_gram(y_vgg['relu5_2']))
And I can't find this part in https://github.com/dxyang/StyleTransfer/blob/master/utils.py Why choose a different layer? Thank you very much.
Hi PangzeCheung, There is no specific reason for the choice. I think both of them are OK.
I found that the layers of vgg you used in the style loss and content loss are different. x_vgg, y_vgg = self.vgg(x), self.vgg(y)
content_loss = 0.0 content_loss += self.weights[0] self.criterion(x_vgg['relu1_1'], y_vgg['relu1_1']) content_loss += self.weights[1] self.criterion(x_vgg['relu2_1'], y_vgg['relu2_1']) content_loss += self.weights[2] self.criterion(x_vgg['relu3_1'], y_vgg['relu3_1']) content_loss += self.weights[3] self.criterion(x_vgg['relu4_1'], y_vgg['relu4_1']) content_loss += self.weights[4] * self.criterion(x_vgg['relu5_1'], y_vgg['relu5_1'])
style_loss = 0.0 style_loss += self.criterion(self.compute_gram(x_vgg['relu2_2']), self.compute_gram(y_vgg['relu2_2'])) style_loss += self.criterion(self.compute_gram(x_vgg['relu3_4']), self.compute_gram(y_vgg['relu3_4'])) style_loss += self.criterion(self.compute_gram(x_vgg['relu4_4']), self.compute_gram(y_vgg['relu4_4'])) style_loss += self.criterion(self.compute_gram(x_vgg['relu5_2']), self.compute_gram(y_vgg['relu5_2']))
And I can't find this part in https://github.com/dxyang/StyleTransfer/blob/master/utils.py Why choose a different layer? Thank you very much.