pytorch

常用的神经网络层:
1 conv2d

torch.nn.Conv2d(in_channels, out_channels, kernel_size, stride=1, padding=0, dilation=1, groups=1, bias=True)

注意是个类,要创建对象后再使用。
参数中的kernel_size, stride, padding, dilation的值,可以为int,也可以为tuple。是int的时候,就代表长宽相等。
Input size为(N,C_in​,H,W);
Output size为(N,C_out​,H_out​,W_out​).
其中,N为batch size,即样本数,C为channel数,H为height,W为width

2 全连接层/线性层 linear

torch.nn.Linear(in_features, out_features, bias=True)

Input size = (N,∗,in_features)
Output size = (N,∗,out_features)

例如:
        self.fc1 = nn.Linear(16*53*53,120)
        self.fc2 = nn.Linear(120,84)

3 Pooling (2D) 层

torch.nn.MaxPool2d(kernel_size, stride=None, padding=0, dilation=1, return_indices=False, ceil_mode=False)
torch.nn.AvgPool2d(kernel_size, stride=None, padding=0, ceil_mode=False, count_include_pad=True)

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值