Pytorch
torch.Tensor
torch.Tensor is a multi-dimensional matrix containing elements of a single data type.
torch.Tensor is an alias for the default tensor type (torch.FloatTensor).
torch.nn.Conv2d
class torch.nn.Conv2d(
in_channels,
out_channels,
kernel_size,
stride=1,
padding=0,
dilation=1,
groups=1,
bias=True)
In the simplest case, the output value of the layer with input size (N,Cin,H,W) and output (N,Cout,Hout,Wout) can be precisely described as:
- ⋆ 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,
- W is width in pixels.
torch.nn.functional.conv2d
torch.nn.functional.conv2d(
input,
weight,
bias=None,
stride=1,
padding=0,
dilation=1,
groups=1) → Tensor
- input – input tensor of shape
- weight – filters of shape
- bias – optional bias tensor of shape (out_channels). Default: None
- stride – the stride of the convolving kernel. Can be a single number or a tuple (sH, sW). Default: 1
- padding – implicit zero paddings on both sides of the input. Can be a single number or a tuple (padH, padW). Default: 0
- dilation – the spacing between kernel elements. Can be a single number or a tuple (dH, dW). Default: 1
- groups – split input into groups, in_channels
- should be divisible by the number of groups. Default: 1
MaxPool2d
class torch.nn.MaxPool2d(
kernel_size,
stride=None,
padding=0,
dilation=1,
return_indices=False,
ceil_mode=False)
torch.tensor permute
>>> x = torch.randn(2, 3, 5)
>>> x.size()
torch.Size([2, 3, 5])
>>> x.permute(2, 0, 1).size()
torch.Size([5, 2, 3])