Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

💡 [REQUEST] - Neural Style Transfer: use AvgPool2d

Đang mở
#3,731 0 bình luận 0 reaction 1 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

@sekyondaMeta đang làm issue này rồi.

Từ ngày 27/4/2026.

Đánh giá

Issue này chưa được đánh giá.

Mô tả

core
🚀 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

cc @albanD @jbschlosser

Ngôn ngữ chính
Python
Star
9.4k
Fork
4.4k
Merge trung bình
3 ngày 5 giờ
Pull request đã merge (30 ngày)
4

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của pytorch/tutorials

Tất cả issue của pytorch/tutorials

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.