The deduced formulas of Conv1d and ConvTranspose1d

torch.nn.Conv1d(in_channelsout_channelskernel_sizestride=1padding=0dilation=1groups=1bias=True)

In the simplest case, the output value of the layer with input size (N,Cin,L) and output (N,Cout,Lout) can be precisely described as:(N,Cout,Lout) can be precisely described as:

out(Ni,Coutj)=bias(Coutj)+Cin1k=0weight(Coutj,k)input(Ni,k)
Parameters:
  • in_channels (int) – Number of channels in the input image
  • out_channels (int) – Number of channels produced by the convolution
  • kernel_size (int or tuple) – Size of the convolving kernel
  • stride (int or tuple, optional) – Stride of the convolution
  • padding (int or tuple, optional) – Zero-padding added to both sides of the input
  • dilation (int or tuple, optional) – Spacing between kernel elements
  • groups (int, optional) – Number of blocked connections from input channels to output channels
  • bias (bool, optional) – If True, adds a learnable bias to the output
Shape:
  • Input: (N,Cin,Lin)
  • Output: (N,Cout,Lout)    where
  • Lout=floor((Lin+2paddingdilation(kernel_size1)1)/stride+1)
Variables:
  • weight (Tensor) – the learnable weights of the module of shape (out_channels, in_channels, kernel_size)
  • bias (Tensor) – the learnable bias of the module of shape (out_channels)

Examples:

>>> m = nn.Conv1d(16, 33, 3, stride=2)
>>> input = autograd.Variable(torch.randn(20, 16, 50))
>>> output = m(input)



________________________________________

torch.nn.ConvTranspose1d(in_channelsout_channelskernel_sizestride=1padding=0output_padding=0groups=1bias=Truedilation=1)

Parameters:
  • in_channels (int) – Number of channels in the input image
  • out_channels (int) – Number of channels produced by the convolution
  • kernel_size (int or tuple) – Size of the convolving kernel
  • stride (int or tuple, optional) – Stride of the convolution
  • padding (int or tuple, optional) – Zero-padding added to both sides of the input
  • output_padding (int or tuple, optional) – Zero-padding added to one side of the output
  • groups (int, optional) – Number of blocked connections from input channels to output channels
  • bias (bool, optional) – If True, adds a learnable bias to the output
Shape:
  • Input: (N,Cin,Lin)(N,Cin,Lin)
  • Output: (N,Cout,Lout) where
  • Lout=(Lin1)stride2padding+kernel_size+output_padding
Variables:
  • weight (Tensor) – the learnable weights of the module of shape (in_channels, out_channels, kernel_size[0], kernel_size[1])
  • bias (Tensor) – the learnable bias of the module of shape (out_channels)
from: http://pytorch.org/docs/0.1.12/nn.html


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值