pytorch - ✅(Solved) Fix Feedback about Conv2d (Request [1 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
pytorch/pytorch#178399Fetched 2026-04-08 01:30:35
View on GitHub
Comments
2
Participants
3
Timeline
28
Reactions
0
Timeline (top)
mentioned ×8subscribed ×8labeled ×6referenced ×3

PR fix notes

PR #178965: Improve Conv2d docs: clarify math variable to parameter mapping and fix cross-correlation link

Description (problem / solution / changelog)

Addresses #178399

  • Extended the variable description after the Conv2d formula to explicitly map math symbols to parameters (C_in → in_channels, C_out → out_channels, etc.)
  • Updated cross-correlation link to point to the discrete functions section of the Wikipedia article, which is more relevant to PyTorch's use case

Changed files

  • torch/nn/modules/conv.py (modified, +5/-3)
RAW_BUFFERClick to expand / collapse

There is the following issue on this page: https://docs.pytorch.org/docs/stable/generated/torch.nn.Conv2d.html#torch.nn.Conv2d

There are a number of variables used in this documentation, and after considerable effort, one can relate those variables to the parameters of the Conv2d function, but the mapping is not made obvious. A tiny section that denotes C_in --> in_channels, C_out --> out_channels, H_in --> kernel_size or kernel_size[0], etc. would be helpful.

There is a small attempt to do something like this in the following paragraph from the documentation:

"where ⋆ is the valid 2D cross-correlation operator, N is a batch size, C denotes a number of channels, H is a height of input planes in pixels, and W is width in pixels."

Yet I don't think it goes far enough. A reader has to figure out on their own that H_in (or H depending on context) is either the parameter kernel_size (if specified as an integer) or the first element of kernel_size if specified as a tuple. The information is eventually made available when describing the specific parameters directly, but it's not obvious when first looking at the initial summation formula.

In addition, the link for the cross-correlation operator is rather misleading. It links to the Wikipedia article, which discusses continuous convolution operators rather than the discrete operators expected by pytorch.

cc @svekars @sekyondaMeta @AlannaBurke @albanD @mruberry @jbschlosser @walterddr @mikaylagawarecki

extent analysis

Fix Plan

To address the issue, we need to add a clarification section to the PyTorch documentation for torch.nn.Conv2d that maps variables used in the documentation to the parameters of the Conv2d function.

Step-by-Step Solution

  • Add a new section to the documentation with a clear mapping of variables to parameters:
### Variable Mapping
The following variables are used in this documentation:
* `C_in`: `in_channels`
* `C_out`: `out_channels`
* `H_in`: `kernel_size` (or `kernel_size[0]` if `kernel_size` is a tuple)
* `W_in`: `kernel_size[1]` (if `kernel_size` is a tuple)
  • Update the existing paragraph to reference this new section:
"where ⋆ is the valid 2D [cross-correlation](https://en.wikipedia.org/wiki/Cross-correlation) operator, 
 N is a batch size, C denotes a number of channels, H is a height of input planes in pixels, and W
 is width in pixels. See the [Variable Mapping](#variable-mapping) section for a description of the variables used in this formula."
  • Replace the link to the Wikipedia article on cross-correlation with a link to a resource that discusses discrete convolution operators, such as the PyTorch documentation on Conv2d.

Verification

To verify that the fix worked, review the updated documentation and ensure that the variable mapping is clear and accurate. Test the link to the cross-correlation operator to ensure it points to a relevant resource.

Extra Tips

  • Consider adding additional examples or diagrams to illustrate the relationship between the variables and parameters.
  • Review other PyTorch documentation pages to ensure consistent variable naming and mapping.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

pytorch - ✅(Solved) Fix Feedback about Conv2d (Request [1 pull requests, 2 comments, 3 participants]