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:
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?
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.
I was reading the documentation for PyTorch’s Conv2d
layer when I encountered this:
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?
padding
parameter accepts int, tuple, or str
.
- If you use
int
as the input, such aspadding = 1
, thenpadding[0] = padding[1] = 1
. - If you use the tuple, such as
padding = (1, 2)
, thenpadding[0] = 1, padding[1] = 2
.
I haven’t tried with str
though.