i see
from torch.modules.utils import _single, _pair, _triple
what does _pair
, _single
, and _triple
, do?
i see
from torch.modules.utils import _single, _pair, _triple
what does _pair
, _single
, and _triple
, do?
These are internal methods (marked via the underscore at the beginning), which repeat some arguments if necessary.
E.g. for nn.Conv2d
you can pass the kernel_size
as a single integer or as a tuple.
In the former case, the tuple will be created via _pair
in this line of code.
So it’s used for convenience, otherwise you would have to specify the complete shapes for each argument.