经典卷积神经网络-ResNet

经典卷积神经网络-ResNet

一、背景介绍

残差神经网络(ResNet)是由微软研究院的何恺明、张祥雨、任少卿、孙剑等人提出的。ResNet 在2015 年的ILSVRC(ImageNet Large Scale Visual Recognition Challenge)中取得了冠军。残差神经网络的主要贡献是发现了“退化现象(Degradation)”,并针对退化现象发明了 “快捷连接(Shortcut connection)”,极大的消除了深度过大的神经网络训练困难问题。神经网络的“深度”首次突破了100层、最大的神经网络甚至超过了1000层。

在这里插入图片描述

二、ResNet网络结构

2.0 残差块

在这里插入图片描述

配合吴恩达深度学习视频中的图片进行讲解:

在这里插入图片描述

如图所示,Residual block就是将 a [ l ] a^{[l]} a[l]传送到 z l + 2 z^{l+2} zl+2上,其相加之后再进行激活得到 a [ l + 2 ] a^{[l+2]} a[l+2]。这一步骤称为"skip connection",即指 a [ l ] a^{[l]} a[l]跳过一层或好几层,从而将信息传递到神经网络的更深层。所以构建一个ResNet网络就是通过将很多这样的残差块堆积在一起,形成一个深度神经网络。

那么引入残差块为什么有效呢? 一个直观上的理解:

在这里插入图片描述

如图所示,假设我们给我们的神经网络再增加两层,我们要得到 a [ l + 2 ] a^{[l+2]} a[l+2],我们通过增加一个残差块来完成。这时 a [ l + 2 ] = g ( z [ l + 2 ] + a [ l ] ) = g ( w [ l + 2 ] a [ l + 1 ] + a [ l ] ) a^{[l+2]}=g(z^{[l+2]}+a^{[l]})=g(w^{[l+2]}a^{[l+1]}+a^{}[l]) a[l+2]=g(z[l+2]+a[l])=g(w[l+2]a[l+1]+a[l]),如果我们应用了L2正则化,此时权重参数会减小,我们可以极端的假设 w [ l + 2 ] = 0 , b [ l + 2 ] = 0 w^{[l+2]}=0,b^{[l+2]}=0 w[l+2]=0b[l+2]=0,那么得到 a [ l + 2 ] = g ( a [ l ] ) = a [ l ] a^{[l+2]}=g(a^{[l]})=a^{[l]} a[l+2]=g(a[l])=a[l](因为使用的是ReLU激活函数,非负的值激活后为原来的值, a [ l ] a^{[l]} a[l]已经经过ReLU激活过了,所以全为非负值)。这意味着,即使给神经网络增加了两层,它的效果并不逊色于更简单的神经网络。所以给大型的神经网络添加残差块来增加网络深度,并不会影响网络的表现。如果我们增加的这两层碰巧能学习到一些有用的信息,那么它就比原来的神经网络表现的更好。

论文中ResNet层数在34及以下和50及以上时采用的是不同的残差块。下面我们分别介绍:

2.1 ResNet-34

在这里插入图片描述

如上图所示是ResNet-34以下采用的残差块,我们将其称作BasicBlock

ResNet-34的网络结构如下:图中实线表示通道数没有变化,虚线表示通道数发生了变化。

在这里插入图片描述

其具体的网络结构如下表:

在这里插入图片描述

2.2 ResNet-50

在这里插入图片描述

如图所示是ResNet-50以上采用的残差块,我们将其称作Bottleneck,使用了1 × 1的卷积来进行通道数的改变,减小计算量。其具体的网络结构见上面的表。

三、论文部分解读

  • 论文中的第一张图就表明了更深层的“plain”神经网络(即不用Residual Learning)的错误率在训练集和测试集上甚至比层数少的“plain”神经网络还要高,所以就引出了问题:训练很深的网络是一个很难的问题。
    在这里插入图片描述

  • 论文中的这张图就表明了,使用Residual Learning后训练更深层的神经网络效果会变得更好。

    在这里插入图片描述

  • 论文中处理残差连接中输入和输出不对等的解决方法:

    • 添加一些额外的0,使得输入和输出的形状可以对应起来可以做相加。
    • 输入和输出不对等的时候使用1 × 1的卷积操作来做投影(目前都是这种方法)
    • 所有的地方都使用1 × 1的卷积来做投影,计算量太大没必要
  • 论文最主要的是提出了residual结构(残差结构),并搭建超深的网络结构(突破1000层)

  • 使用了大量BN来加速训练(丢弃dropout)

  • 论文中对CIFAR10数据集做了大量实验验证其效果,最后还将ResNet用到了目标检测领域

三、ResNet-18的Pytorch实现

import torch
import torch.nn as nn
import torchsummary# BasicBlock
class BasicBlock(nn.Module):def __init__(self, in_channels, out_channels, stride=1):super(BasicBlock, self).__init__()# 第一个卷积有可能要进行下采样 即将输出通道翻倍 输出数据大小全部减半# 所以我们让第一个卷积的stride设置为可传入的参数# 如果要进行BN 卷积就不需要加偏置self.conv1 = nn.Conv2d(in_channels, out_channels, kernel_size=3, stride=stride, padding=1, bias=False)self.bn1 = nn.BatchNorm2d(out_channels)self.relu = nn.ReLU(inplace=True)# 第二个卷积保持尺寸和通道数self.conv2 = nn.Conv2d(out_channels, out_channels, kernel_size=3, stride=1, padding=1, bias=False)self.bn2 = nn.BatchNorm2d(out_channels)# 如果最后输入和输出的通道数不一样 那么就用1 × 1的卷积调节输入 方便后面能和输出相加# shortcut操作也是downsample(下采样) 即将输出通道翻倍 输出数据大小全部减半# 这一步主要做的就是为了能让最后的输出数据和输入数据"连接"上 即相加self.shortcut = nn.Sequential()if stride != 1 or in_channels != out_channels:self.shortcut = nn.Sequential(nn.Conv2d(in_channels, out_channels, stride=stride, kernel_size=1, bias=False),nn.BatchNorm2d(out_channels))def forward(self, x):# 记录identityidentity = xout = self.conv1(x)out = self.bn1(out)out = self.relu(out)out = self.conv2(out)out = self.bn2(out)# 进行残差连接out += self.shortcut(identity)# 残差连接之后激活out = self.relu(out)return out# ResNet-18
class ResNet18(nn.Module):def __init__(self, num_classes=1000):super(ResNet18, self).__init__()# output_size = [(input_size - kernel_size + 2padding) / stride] + 1# 112 = [(224 - 7 + 2padding) / stride] + 1 -> padding = 3self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3, bias=False)self.bn1 = nn.BatchNorm2d(64)self.relu = nn.ReLU(inplace=True)# 56 = [(112 - 3 + 2padding) / 2] + 1 -> padding = 1self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)self.layer1 = self._make_layer(in_channels=64, out_channels=64, blocks=2, stride=1)self.layer2 = self._make_layer(in_channels=64, out_channels=128, blocks=2, stride=2)self.layer3 = self._make_layer(in_channels=128, out_channels=256, blocks=2, stride=2)self.layer4 = self._make_layer(in_channels=256, out_channels=512, blocks=2, stride=2)# 平均池化 参数就是out_sizeself.avgpool = nn.AdaptiveAvgPool2d((1, 1))self.fc = nn.Linear(512, num_classes)def _make_layer(self, in_channels, out_channels, blocks, stride=1):layer = []# 因为第一个残差块的输入通道可能与输出通道不同 所以单独拿出来赋值layer.append(BasicBlock(in_channels, out_channels, stride))for _ in range(1, blocks):layer.append(BasicBlock(out_channels, out_channels))return nn.Sequential(*layer)def forward(self, x):out = self.conv1(x)out = self.bn1(out)out = self.relu(out)out = self.maxpool(out)out = self.layer1(out)out = self.layer2(out)out = self.layer3(out)out = self.layer4(out)out = self.avgpool(out)out = torch.flatten(out, 1)out = self.fc(out)return outif __name__ == '__main__':DEVICE = "cuda" if torch.cuda.is_available() else "cpu"model = (ResNet18())model.to(DEVICE)# print(model)print(torch.cuda.is_available())torchsummary.summary(model, (3, 224, 224), 64)

主要注意点是:

  • BasicBlock(34层以下的残差块)中残差连接的方法,注意输入和输出的通道数,用1×1的卷积做好尺寸和维度对齐。
  • 使用_make_layer()函数批量生成残差块。

在控制台输出网络结构:

ResNet18((conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)(layer1): Sequential((0): BasicBlock((conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(shortcut): Sequential())(1): BasicBlock((conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(shortcut): Sequential()))(layer2): Sequential((0): BasicBlock((conv1): Conv2d(64, 128, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)(bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(shortcut): Sequential((0): Conv2d(64, 128, kernel_size=(1, 1), stride=(2, 2), bias=False)(1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)))(1): BasicBlock((conv1): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(shortcut): Sequential()))(layer3): Sequential((0): BasicBlock((conv1): Conv2d(128, 256, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)(bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(shortcut): Sequential((0): Conv2d(128, 256, kernel_size=(1, 1), stride=(2, 2), bias=False)(1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)))(1): BasicBlock((conv1): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(shortcut): Sequential()))(layer4): Sequential((0): BasicBlock((conv1): Conv2d(256, 512, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)(bn1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(shortcut): Sequential((0): Conv2d(256, 512, kernel_size=(1, 1), stride=(2, 2), bias=False)(1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)))(1): BasicBlock((conv1): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(shortcut): Sequential()))(avgpool): AdaptiveAvgPool2d(output_size=(1, 1))(fc): Linear(in_features=512, out_features=1000, bias=True)
)

使用torchsummary来测试网络:

----------------------------------------------------------------Layer (type)               Output Shape         Param #
================================================================Conv2d-1         [64, 64, 112, 112]           9,408BatchNorm2d-2         [64, 64, 112, 112]             128ReLU-3         [64, 64, 112, 112]               0MaxPool2d-4           [64, 64, 56, 56]               0Conv2d-5           [64, 64, 56, 56]          36,864BatchNorm2d-6           [64, 64, 56, 56]             128ReLU-7           [64, 64, 56, 56]               0Conv2d-8           [64, 64, 56, 56]          36,864BatchNorm2d-9           [64, 64, 56, 56]             128ReLU-10           [64, 64, 56, 56]               0BasicBlock-11           [64, 64, 56, 56]               0Conv2d-12           [64, 64, 56, 56]          36,864BatchNorm2d-13           [64, 64, 56, 56]             128ReLU-14           [64, 64, 56, 56]               0Conv2d-15           [64, 64, 56, 56]          36,864BatchNorm2d-16           [64, 64, 56, 56]             128ReLU-17           [64, 64, 56, 56]               0BasicBlock-18           [64, 64, 56, 56]               0Conv2d-19          [64, 128, 28, 28]          73,728BatchNorm2d-20          [64, 128, 28, 28]             256ReLU-21          [64, 128, 28, 28]               0Conv2d-22          [64, 128, 28, 28]         147,456BatchNorm2d-23          [64, 128, 28, 28]             256Conv2d-24          [64, 128, 28, 28]           8,192BatchNorm2d-25          [64, 128, 28, 28]             256ReLU-26          [64, 128, 28, 28]               0BasicBlock-27          [64, 128, 28, 28]               0Conv2d-28          [64, 128, 28, 28]         147,456BatchNorm2d-29          [64, 128, 28, 28]             256ReLU-30          [64, 128, 28, 28]               0Conv2d-31          [64, 128, 28, 28]         147,456BatchNorm2d-32          [64, 128, 28, 28]             256ReLU-33          [64, 128, 28, 28]               0BasicBlock-34          [64, 128, 28, 28]               0Conv2d-35          [64, 256, 14, 14]         294,912BatchNorm2d-36          [64, 256, 14, 14]             512ReLU-37          [64, 256, 14, 14]               0Conv2d-38          [64, 256, 14, 14]         589,824BatchNorm2d-39          [64, 256, 14, 14]             512Conv2d-40          [64, 256, 14, 14]          32,768BatchNorm2d-41          [64, 256, 14, 14]             512ReLU-42          [64, 256, 14, 14]               0BasicBlock-43          [64, 256, 14, 14]               0Conv2d-44          [64, 256, 14, 14]         589,824BatchNorm2d-45          [64, 256, 14, 14]             512ReLU-46          [64, 256, 14, 14]               0Conv2d-47          [64, 256, 14, 14]         589,824BatchNorm2d-48          [64, 256, 14, 14]             512ReLU-49          [64, 256, 14, 14]               0BasicBlock-50          [64, 256, 14, 14]               0Conv2d-51            [64, 512, 7, 7]       1,179,648BatchNorm2d-52            [64, 512, 7, 7]           1,024ReLU-53            [64, 512, 7, 7]               0Conv2d-54            [64, 512, 7, 7]       2,359,296BatchNorm2d-55            [64, 512, 7, 7]           1,024Conv2d-56            [64, 512, 7, 7]         131,072BatchNorm2d-57            [64, 512, 7, 7]           1,024ReLU-58            [64, 512, 7, 7]               0BasicBlock-59            [64, 512, 7, 7]               0Conv2d-60            [64, 512, 7, 7]       2,359,296BatchNorm2d-61            [64, 512, 7, 7]           1,024ReLU-62            [64, 512, 7, 7]               0Conv2d-63            [64, 512, 7, 7]       2,359,296BatchNorm2d-64            [64, 512, 7, 7]           1,024ReLU-65            [64, 512, 7, 7]               0BasicBlock-66            [64, 512, 7, 7]               0
AdaptiveAvgPool2d-67            [64, 512, 1, 1]               0Linear-68                 [64, 1000]         513,000
================================================================
Total params: 11,689,512
Trainable params: 11,689,512
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 36.75
Forward/backward pass size (MB): 4018.74
Params size (MB): 44.59
Estimated Total Size (MB): 4100.08
----------------------------------------------------------------

四、ResNet-50的Pytorch实现

import torch
import torch.nn as nn
import torchsummary# Bottleneck
class Bottleneck(nn.Module):# expansion = 4,因为Bottleneck中每个残差结构输出维度都是输入维度的4倍expansion = 4def __init__(self, in_channels, out_channels, stride=1):super(Bottleneck, self).__init__()# 注意这里1×1的卷积不用paddingself.conv1 = nn.Conv2d(in_channels, out_channels, kernel_size=1, stride=stride, bias=False)self.bn1 = nn.BatchNorm2d(out_channels)# 维持特征图尺寸 padding = 1self.conv2 = nn.Conv2d(out_channels, out_channels, kernel_size=3, stride=1, padding=1, bias=False)self.bn2 = nn.BatchNorm2d(out_channels)# 注意这里1×1的卷积不用paddingself.conv3 = nn.Conv2d(out_channels, out_channels * self.expansion, kernel_size=1, stride=1, bias=False)self.bn3 = nn.BatchNorm2d(out_channels * self.expansion)self.relu = nn.ReLU(inplace=True)self.shortcut = nn.Sequential()if stride != 1 or in_channels != out_channels * self.expansion:self.shortcut = nn.Sequential(nn.Conv2d(in_channels, out_channels * self.expansion, stride=stride, kernel_size=1, bias=False),nn.BatchNorm2d(out_channels * self.expansion))def forward(self, x):identity = xout = self.conv1(x)out = self.bn1(out)out = self.relu(out)out = self.conv2(out)out = self.bn2(out)out = self.relu(out)out = self.conv3(out)out = self.bn3(out)# 残差连接out += self.shortcut(identity)out = self.relu(out)return out# ResNet50
class ResNet50(nn.Module):def __init__(self, num_classes=1000):super(ResNet50, self).__init__()# output_size = [(input_size - kernel_size + 2padding) / stride] + 1# 112 = [(224 - 7 + 2padding) / stride] + 1 -> padding = 3self.conv1 = nn.Conv2d(3, 64, kernel_size=7, stride=2, padding=3, bias=False)self.bn1 = nn.BatchNorm2d(64)self.relu = nn.ReLU(inplace=True)# 56 = [(112 - 3 + 2padding) / 2] + 1 -> padding = 1self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)self.layer1 = self._make_layer(64, 64, blocks=3, stride=1)self.layer2 = self._make_layer(256, 128, blocks=4, stride=2)self.layer3 = self._make_layer(512, 256, blocks=6, stride=2)self.layer4 = self._make_layer(1024, 512, blocks=3, stride=2)# 平均池化 参数就是out_sizeself.avgpool = nn.AdaptiveAvgPool2d((1, 1))self.fc = nn.Linear(2048, num_classes)def _make_layer(self, in_channels, out_channels, blocks, stride=1):layer = []# 因为第一个残差块的输入通道可能与输出通道不同 所以单独拿出来赋值layer.append(Bottleneck(in_channels, out_channels, stride))for _ in range(1, blocks):# 接下来的每一个其输入通道都是输出的四倍layer.append(Bottleneck(out_channels * 4, out_channels))return nn.Sequential(*layer)def forward(self, x):out = self.conv1(x)out = self.bn1(out)out = self.relu(out)out = self.maxpool(out)out = self.layer1(out)out = self.layer2(out)out = self.layer3(out)out = self.layer4(out)out = self.avgpool(out)out = torch.flatten(out, 1)out = self.fc(out)return outif __name__ == '__main__':DEVICE = "cuda" if torch.cuda.is_available() else "cpu"model = ResNet50()model.to(DEVICE)# print(model)torchsummary.summary(model, (3, 224, 224), 64)

主要注意点是:

  • Bottleneck(50层以上残差块)中块与块直接连接的通道数问题。在BasicBlock中由于两个相同的块在连接的时候通道数是相同的,而Bottleneck中两个相同的块在连接的时候其通道数相差四倍。即下面这段代码:

        for _ in range(1, blocks):# 接下来的每一个其输入通道都是输出的四倍layer.append(Bottleneck(out_channels * 4, out_channels))
    
  • 注意最后全连接的通道数,ResNet50以上的最后全连接的in_features为2048。

  • 注意在残差连接的时候,shortcut调整的维度一定要和输出维度对上,即下面这段代码:

    self.shortcut = nn.Sequential()
    if stride != 1 or in_channels != out_channels * self.expansion:self.shortcut = nn.Sequential(nn.Conv2d(in_channels, out_channels * self.expansion, stride=stride, kernel_size=1, bias=False),nn.BatchNorm2d(out_channels * self.expansion))
    
  • 写代码的时候,要注意只有每一堆残差块结构中的第一个残差块的第一个卷积操作的stride为2,其余都为1,(除了第一堆残差块要维持尺度不变),即:

    self.layer1 = self._make_layer(64, 64, blocks=3, stride=1)
    

在控制台输出网络结构:

ResNet50((conv1): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(maxpool): MaxPool2d(kernel_size=3, stride=2, padding=1, dilation=1, ceil_mode=False)(layer1): Sequential((0): Bottleneck((conv1): Conv2d(64, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential((0): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)(1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)))(1): Bottleneck((conv1): Conv2d(256, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential())(2): Bottleneck((conv1): Conv2d(256, 64, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(64, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential()))(layer2): Sequential((0): Bottleneck((conv1): Conv2d(256, 128, kernel_size=(1, 1), stride=(2, 2), bias=False)(bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(128, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential((0): Conv2d(256, 512, kernel_size=(1, 1), stride=(2, 2), bias=False)(1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)))(1): Bottleneck((conv1): Conv2d(512, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(128, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential())(2): Bottleneck((conv1): Conv2d(512, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(128, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential())(3): Bottleneck((conv1): Conv2d(512, 128, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn1): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(128, 128, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(128, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(128, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential()))(layer3): Sequential((0): Bottleneck((conv1): Conv2d(512, 256, kernel_size=(1, 1), stride=(2, 2), bias=False)(bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(256, 1024, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential((0): Conv2d(512, 1024, kernel_size=(1, 1), stride=(2, 2), bias=False)(1): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)))(1): Bottleneck((conv1): Conv2d(1024, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(256, 1024, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential())(2): Bottleneck((conv1): Conv2d(1024, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(256, 1024, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential())(3): Bottleneck((conv1): Conv2d(1024, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(256, 1024, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential())(4): Bottleneck((conv1): Conv2d(1024, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(256, 1024, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential())(5): Bottleneck((conv1): Conv2d(1024, 256, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn1): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(256, 256, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(256, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(256, 1024, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(1024, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential()))(layer4): Sequential((0): Bottleneck((conv1): Conv2d(1024, 512, kernel_size=(1, 1), stride=(2, 2), bias=False)(bn1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(512, 2048, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(2048, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential((0): Conv2d(1024, 2048, kernel_size=(1, 1), stride=(2, 2), bias=False)(1): BatchNorm2d(2048, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)))(1): Bottleneck((conv1): Conv2d(2048, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(512, 2048, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(2048, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential())(2): Bottleneck((conv1): Conv2d(2048, 512, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn1): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv2): Conv2d(512, 512, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)(bn2): BatchNorm2d(512, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(conv3): Conv2d(512, 2048, kernel_size=(1, 1), stride=(1, 1), bias=False)(bn3): BatchNorm2d(2048, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)(relu): ReLU(inplace=True)(shortcut): Sequential()))(avgpool): AdaptiveAvgPool2d(output_size=(1, 1))(fc): Linear(in_features=2048, out_features=1000, bias=True)
)

使用torchsummary来测试网络:

----------------------------------------------------------------Layer (type)               Output Shape         Param #
================================================================Conv2d-1         [64, 64, 112, 112]           9,408BatchNorm2d-2         [64, 64, 112, 112]             128ReLU-3         [64, 64, 112, 112]               0MaxPool2d-4           [64, 64, 56, 56]               0Conv2d-5           [64, 64, 56, 56]           4,096BatchNorm2d-6           [64, 64, 56, 56]             128ReLU-7           [64, 64, 56, 56]               0Conv2d-8           [64, 64, 56, 56]          36,864BatchNorm2d-9           [64, 64, 56, 56]             128ReLU-10           [64, 64, 56, 56]               0Conv2d-11          [64, 256, 56, 56]          16,384BatchNorm2d-12          [64, 256, 56, 56]             512Conv2d-13          [64, 256, 56, 56]          16,384BatchNorm2d-14          [64, 256, 56, 56]             512ReLU-15          [64, 256, 56, 56]               0Bottleneck-16          [64, 256, 56, 56]               0Conv2d-17           [64, 64, 56, 56]          16,384BatchNorm2d-18           [64, 64, 56, 56]             128ReLU-19           [64, 64, 56, 56]               0Conv2d-20           [64, 64, 56, 56]          36,864BatchNorm2d-21           [64, 64, 56, 56]             128ReLU-22           [64, 64, 56, 56]               0Conv2d-23          [64, 256, 56, 56]          16,384BatchNorm2d-24          [64, 256, 56, 56]             512ReLU-25          [64, 256, 56, 56]               0Bottleneck-26          [64, 256, 56, 56]               0Conv2d-27           [64, 64, 56, 56]          16,384BatchNorm2d-28           [64, 64, 56, 56]             128ReLU-29           [64, 64, 56, 56]               0Conv2d-30           [64, 64, 56, 56]          36,864BatchNorm2d-31           [64, 64, 56, 56]             128ReLU-32           [64, 64, 56, 56]               0Conv2d-33          [64, 256, 56, 56]          16,384BatchNorm2d-34          [64, 256, 56, 56]             512ReLU-35          [64, 256, 56, 56]               0Bottleneck-36          [64, 256, 56, 56]               0Conv2d-37          [64, 128, 28, 28]          32,768BatchNorm2d-38          [64, 128, 28, 28]             256ReLU-39          [64, 128, 28, 28]               0Conv2d-40          [64, 128, 28, 28]         147,456BatchNorm2d-41          [64, 128, 28, 28]             256ReLU-42          [64, 128, 28, 28]               0Conv2d-43          [64, 512, 28, 28]          65,536BatchNorm2d-44          [64, 512, 28, 28]           1,024Conv2d-45          [64, 512, 28, 28]         131,072BatchNorm2d-46          [64, 512, 28, 28]           1,024ReLU-47          [64, 512, 28, 28]               0Bottleneck-48          [64, 512, 28, 28]               0Conv2d-49          [64, 128, 28, 28]          65,536BatchNorm2d-50          [64, 128, 28, 28]             256ReLU-51          [64, 128, 28, 28]               0Conv2d-52          [64, 128, 28, 28]         147,456BatchNorm2d-53          [64, 128, 28, 28]             256ReLU-54          [64, 128, 28, 28]               0Conv2d-55          [64, 512, 28, 28]          65,536BatchNorm2d-56          [64, 512, 28, 28]           1,024ReLU-57          [64, 512, 28, 28]               0Bottleneck-58          [64, 512, 28, 28]               0Conv2d-59          [64, 128, 28, 28]          65,536BatchNorm2d-60          [64, 128, 28, 28]             256ReLU-61          [64, 128, 28, 28]               0Conv2d-62          [64, 128, 28, 28]         147,456BatchNorm2d-63          [64, 128, 28, 28]             256ReLU-64          [64, 128, 28, 28]               0Conv2d-65          [64, 512, 28, 28]          65,536BatchNorm2d-66          [64, 512, 28, 28]           1,024ReLU-67          [64, 512, 28, 28]               0Bottleneck-68          [64, 512, 28, 28]               0Conv2d-69          [64, 128, 28, 28]          65,536BatchNorm2d-70          [64, 128, 28, 28]             256ReLU-71          [64, 128, 28, 28]               0Conv2d-72          [64, 128, 28, 28]         147,456BatchNorm2d-73          [64, 128, 28, 28]             256ReLU-74          [64, 128, 28, 28]               0Conv2d-75          [64, 512, 28, 28]          65,536BatchNorm2d-76          [64, 512, 28, 28]           1,024ReLU-77          [64, 512, 28, 28]               0Bottleneck-78          [64, 512, 28, 28]               0Conv2d-79          [64, 256, 14, 14]         131,072BatchNorm2d-80          [64, 256, 14, 14]             512ReLU-81          [64, 256, 14, 14]               0Conv2d-82          [64, 256, 14, 14]         589,824BatchNorm2d-83          [64, 256, 14, 14]             512ReLU-84          [64, 256, 14, 14]               0Conv2d-85         [64, 1024, 14, 14]         262,144BatchNorm2d-86         [64, 1024, 14, 14]           2,048Conv2d-87         [64, 1024, 14, 14]         524,288BatchNorm2d-88         [64, 1024, 14, 14]           2,048ReLU-89         [64, 1024, 14, 14]               0Bottleneck-90         [64, 1024, 14, 14]               0Conv2d-91          [64, 256, 14, 14]         262,144BatchNorm2d-92          [64, 256, 14, 14]             512ReLU-93          [64, 256, 14, 14]               0Conv2d-94          [64, 256, 14, 14]         589,824BatchNorm2d-95          [64, 256, 14, 14]             512ReLU-96          [64, 256, 14, 14]               0Conv2d-97         [64, 1024, 14, 14]         262,144BatchNorm2d-98         [64, 1024, 14, 14]           2,048ReLU-99         [64, 1024, 14, 14]               0Bottleneck-100         [64, 1024, 14, 14]               0Conv2d-101          [64, 256, 14, 14]         262,144BatchNorm2d-102          [64, 256, 14, 14]             512ReLU-103          [64, 256, 14, 14]               0Conv2d-104          [64, 256, 14, 14]         589,824BatchNorm2d-105          [64, 256, 14, 14]             512ReLU-106          [64, 256, 14, 14]               0Conv2d-107         [64, 1024, 14, 14]         262,144BatchNorm2d-108         [64, 1024, 14, 14]           2,048ReLU-109         [64, 1024, 14, 14]               0Bottleneck-110         [64, 1024, 14, 14]               0Conv2d-111          [64, 256, 14, 14]         262,144BatchNorm2d-112          [64, 256, 14, 14]             512ReLU-113          [64, 256, 14, 14]               0Conv2d-114          [64, 256, 14, 14]         589,824BatchNorm2d-115          [64, 256, 14, 14]             512ReLU-116          [64, 256, 14, 14]               0Conv2d-117         [64, 1024, 14, 14]         262,144BatchNorm2d-118         [64, 1024, 14, 14]           2,048ReLU-119         [64, 1024, 14, 14]               0Bottleneck-120         [64, 1024, 14, 14]               0Conv2d-121          [64, 256, 14, 14]         262,144BatchNorm2d-122          [64, 256, 14, 14]             512ReLU-123          [64, 256, 14, 14]               0Conv2d-124          [64, 256, 14, 14]         589,824BatchNorm2d-125          [64, 256, 14, 14]             512ReLU-126          [64, 256, 14, 14]               0Conv2d-127         [64, 1024, 14, 14]         262,144BatchNorm2d-128         [64, 1024, 14, 14]           2,048ReLU-129         [64, 1024, 14, 14]               0Bottleneck-130         [64, 1024, 14, 14]               0Conv2d-131          [64, 256, 14, 14]         262,144BatchNorm2d-132          [64, 256, 14, 14]             512ReLU-133          [64, 256, 14, 14]               0Conv2d-134          [64, 256, 14, 14]         589,824BatchNorm2d-135          [64, 256, 14, 14]             512ReLU-136          [64, 256, 14, 14]               0Conv2d-137         [64, 1024, 14, 14]         262,144BatchNorm2d-138         [64, 1024, 14, 14]           2,048ReLU-139         [64, 1024, 14, 14]               0Bottleneck-140         [64, 1024, 14, 14]               0Conv2d-141            [64, 512, 7, 7]         524,288BatchNorm2d-142            [64, 512, 7, 7]           1,024ReLU-143            [64, 512, 7, 7]               0Conv2d-144            [64, 512, 7, 7]       2,359,296BatchNorm2d-145            [64, 512, 7, 7]           1,024ReLU-146            [64, 512, 7, 7]               0Conv2d-147           [64, 2048, 7, 7]       1,048,576BatchNorm2d-148           [64, 2048, 7, 7]           4,096Conv2d-149           [64, 2048, 7, 7]       2,097,152BatchNorm2d-150           [64, 2048, 7, 7]           4,096ReLU-151           [64, 2048, 7, 7]               0Bottleneck-152           [64, 2048, 7, 7]               0Conv2d-153            [64, 512, 7, 7]       1,048,576BatchNorm2d-154            [64, 512, 7, 7]           1,024ReLU-155            [64, 512, 7, 7]               0Conv2d-156            [64, 512, 7, 7]       2,359,296BatchNorm2d-157            [64, 512, 7, 7]           1,024ReLU-158            [64, 512, 7, 7]               0Conv2d-159           [64, 2048, 7, 7]       1,048,576BatchNorm2d-160           [64, 2048, 7, 7]           4,096ReLU-161           [64, 2048, 7, 7]               0Bottleneck-162           [64, 2048, 7, 7]               0Conv2d-163            [64, 512, 7, 7]       1,048,576BatchNorm2d-164            [64, 512, 7, 7]           1,024ReLU-165            [64, 512, 7, 7]               0Conv2d-166            [64, 512, 7, 7]       2,359,296BatchNorm2d-167            [64, 512, 7, 7]           1,024ReLU-168            [64, 512, 7, 7]               0Conv2d-169           [64, 2048, 7, 7]       1,048,576BatchNorm2d-170           [64, 2048, 7, 7]           4,096ReLU-171           [64, 2048, 7, 7]               0Bottleneck-172           [64, 2048, 7, 7]               0
AdaptiveAvgPool2d-173           [64, 2048, 1, 1]               0Linear-174                 [64, 1000]       2,049,000
================================================================
Total params: 25,557,032
Trainable params: 25,557,032
Non-trainable params: 0
----------------------------------------------------------------
Input size (MB): 36.75
Forward/backward pass size (MB): 15200.01
Params size (MB): 97.49
Estimated Total Size (MB): 15334.25
----------------------------------------------------------------

参考链接:

  • https://link.zhihu.com/?target=https%3A//arxiv.org/pdf/1512.03385.pdf

  • https://blog.csdn.net/m0_64799972/article/details/132753608

  • https://blog.csdn.net/m0_50127633/article/details/117200212

  • https://www.bilibili.com/video/BV1Bo4y1T7Lc/?spm_id_from=333.999.0.0&vd_source=c7e390079ff3e10b79e23fb333bea49d

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/314686.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Vue中全局事件总线的配置和原理

实现任意组件之间的通信 任意组件通信的原理: 1、实现任意组件之间的通信,需要一个傀儡。这个傀儡既能被vm访问到,也能被VueComponent访问。 2、VueComponent.prototype.proto Vue.prototype为图上1.0黄色的线路。是Vue让组件实例对象VueComponent可以访问到Vue原…

跟着cherno手搓游戏引擎【3】事件系统和预编译头文件

不多说了直接上代码,课程中的架构讲的比较宽泛,而且有些方法写完之后并未测试。所以先把代码写完。理解其原理,未来使用时候会再此完善此博客。 文件架构: Event.h:核心基类 #pragma once #include"../Core.h" #inclu…

大二第17周总结——2023年的最后一天

本周,学校安排的是数据结构的程序设计,设计是挺好设计的,小半天搞完了,然后帮室友也搞了。内容在上一个博客。 学习上嘛~ 学了一下websocket,看了下微信小程序........ 今天早上做了一套小米的面试题,不做不知道&…

【数据库原理】(1)数据库技术的发展

数据与信息 数据:数据并非只是数字,像文字、符号、图像、影音等都属于数据的范畴。但一般会用数字来表述客观事物的数量、质量、关系等,便于更加直观的看待问题。 语义:数据还需要结合关联的语义解释才能够清晰的描述事物&#…

CMake入门教程【基础篇】CMake+vs2022+nmake构建项目

文章目录 1.vs编译器下载安装2.运行nmake测试3.CMake下载安装4.运行CMake测试5.使用CMakeNMake构建项目代码目录代码实现 6.运行项目 1.vs编译器下载安装 下载地址 :https://visualstudio.microsoft.com/zh-hans/vs/ 点击截图处下载 勾选红框的内容即可 安装 2.运行nmak…

【Matlab】LSTM长短期记忆神经网络时序预测算法(附代码)

资源下载: https://download.csdn.net/download/vvoennvv/88688439 一,概述 LSTM(Long Short-Term Memory)是一种常用的循环神经网络(Recurrent Neural Network,RNN)结构,由于其对于…

【解决复杂链式任务打造全能助手】大模型思维链 CoT 应用:LangChain 大模型 结合 做 AutoGPT

大模型思维链 CoT 应用:langchain 大模型 结合 做 AutoGPT,解决复杂链式任务打造全能助手 思维链 CoTLangChain基础层:models、LLMs、index能力层:Chains、Memory、Tools应用层:文档问答、数据库问答、智能体Agents La…

航芯ACM32G103开发板评测 03 RT-Thread Nano移植 线程管理测试

航芯ACM32G103开发板评测 07 RT-Thread Nano移植 线程管理测试 1. 软硬件平台 ACM32G103 Board开发板MDK-ARM KeilRT-Thread Nano 源码 2. 物联网RTOS—RT-Thread ​ RT-Thread诞生于2006年,是一款以开源、中立、社区化发展起来的物联网操作系统。 RT-Thread主…

FL Studio Producer Edition 21.2.2中文版所有插件版及使用教程

FL Studio 21.2.2中文版惯称水果编曲, 是一个完整的电音软件音乐制作环境或数字音频工作站。是现在流行的数字音频工作站之一,包括撰写,整理,记录,编辑,电音,混音和掌握专业品质的音乐。 FL Studio Producer Edition 21.2.2.3914 所有插件版是一款功能强大的软件音乐制作环境或…

TF-IDF(Term Frequency-Inverse Document Frequency)算法 简介

TF-IDF(Term Frequency-Inverse Document Frequency)是一种用于信息检索和文本挖掘的常用算法。它用于评估一个词对于一个文档集合中某个文档的重要性。 这个算法的基本思想是:如果一个词在一个文档中频繁出现,并且在整个文档集合…

rime中州韵 help lua Translator

lua 是 Rime中州韵/小狼毫输入法强大的武器,掌握如何在Rime中州韵/小狼毫中使用lua,你将体验到什么叫 随心所欲。 先看效果 在 rime中州韵 输入效果一览 中的 👇 help效果 一节中, 我们看到了在Rime中州韵/小狼毫输入法中输入 h…

项目 杂碎 知识点 汇总!!!

Vue !!! setup生命周期 使用 nextTick !!获取节点 onMounted中可以使用JS,获取节点,setup生命周期无法获取节点 vue实现文本粘贴复制 Vue遍历对象 1、使用v-for指令:可以直接遍历对象的键和值 2、使用 Object.keys…