-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Open
Description
🚀 Describe the improvement or the new tutorial
Neural Style Transfer utilizes VGG network, which uses maximum pooling.
Although Original article suggests using average pooling instead for better results:
For image synthesis we found that replacing the maximum
pooling operation by average pooling yields slightly more
appealing results, which is why the images shown were generated with average pooling.
This is unsurprising, considering that max pooling may hide gradients of lower layers, while average pooling preserves them, so gradient descent for reconstructing image works better.
I confirm that it actually improves results.
Suggested changes
Replace that:
elif isinstance(layer, nn.MaxPool2d):
name = 'pool_{}'.format(i)with that:
elif isinstance(layer, nn.MaxPool2d):
name = 'pool_{}'.format(i)
layer = nn.AvgPool2d(
kernel_size=layer.kernel_size,
stride=layer.stride,
padding=layer.padding,
ceil_mode=layer.ceil_mode)Existing tutorials on this topic
https://docs.pytorch.org/tutorials/advanced/neural_style_tutorial.html
Additional context
No response
Metadata
Metadata
Assignees
Labels
No labels