Pytorch学习——常用函数

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])
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值