What do the indices mean for the input/output in PyTorch's documentation?

Question:

I was reading the documentation for PyTorch’s Conv2d layer when I encountered this:

enter image description here

What exactly do the indices behind the parameter names in the input/output section mean? padding[0], dilation[0], etc.

Is the reference only applicable when the layer is provided with a tuple? In other words, if a scalar value is provided, does it mean that all references are the same? Can anyone provide some clarification on this matter?

Asked By: AlanSTACK

||

Answers:

padding parameter accepts int, tuple, or str.

  • If you use int as the input, such as padding = 1, then padding[0] = padding[1] = 1.
  • If you use the tuple, such as padding = (1, 2), then padding[0] = 1, padding[1] = 2.

I haven’t tried with str though.

Answered By: Minh-Long Luu
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.