做ppt素材的網(wǎng)站開創(chuàng)集團(tuán)與百度
深度學(xué)習(xí)-解讀GoogleNet深度學(xué)習(xí)網(wǎng)絡(luò)
深度學(xué)習(xí)中,經(jīng)典網(wǎng)絡(luò)引領(lǐng)一波又一波的技術(shù)革命,從LetNet到當(dāng)前最火的GPT所用的Transformer,它們把AI技術(shù)不斷推向高潮。2012年AlexNet大放異彩,它把深度學(xué)習(xí)技術(shù)引領(lǐng)第一個(gè)高峰,打開人們的視野。
用pytorch構(gòu)建CNN經(jīng)典網(wǎng)絡(luò)模型GoogleNet,又稱為Inception V1 ,還可以用數(shù)據(jù)進(jìn)行訓(xùn)練模型,得到一個(gè)優(yōu)化的模型。
深度學(xué)習(xí)
深度學(xué)習(xí)-回顧經(jīng)典AlexNet網(wǎng)絡(luò):山高我為峰-CSDN博客
深度學(xué)習(xí)-CNN網(wǎng)絡(luò)改進(jìn)版LetNet5-CSDN博客
深度學(xué)習(xí)-回顧C(jī)NN經(jīng)典網(wǎng)絡(luò)LetNet-CSDN博客
GPT實(shí)戰(zhàn)系列-如何用自己數(shù)據(jù)微調(diào)ChatGLM2模型訓(xùn)練_pytorch 訓(xùn)練chatglm2 模型-CSDN博客
Caffe筆記:python圖像識(shí)別與分類_python 怎么識(shí)別 caffe-CSDN博客
深度學(xué)習(xí)-Pytorch同時(shí)使用Numpy和Tensors各自特效-CSDN博客
深度學(xué)習(xí)-Pytorch運(yùn)算的基本數(shù)據(jù)類型_pytorch支持的訓(xùn)練數(shù)據(jù)類型-CSDN博客
深度學(xué)習(xí)-Pytorch如何保存和加載模型
深度學(xué)習(xí)-Pytorch如何構(gòu)建和訓(xùn)練模型-CSDN博客
深度學(xué)習(xí)-Pytorch數(shù)據(jù)集構(gòu)造和分批加載-CSDN博客
Python Faster R-CNN 安裝配置記錄_attributeerror: has no attribute 'smooth_l1_loss-CSDN博客
經(jīng)典算法-遺傳算法的python實(shí)現(xiàn)
經(jīng)典算法-模擬退火算法的python實(shí)現(xiàn)
經(jīng)典算法-粒子群算法的python實(shí)現(xiàn)-CSDN博客
GoogleNet概述
GoogLeNet是2014年Christian Szegedy提出的一種全新的深度學(xué)習(xí)結(jié)構(gòu),和VGGNet同一年誕生,獲得2014年ILSVRC競(jìng)賽的第一名。
在這之前的AlexNet、VGG等結(jié)構(gòu)都是通過(guò)增大網(wǎng)絡(luò)的深度(層數(shù))來(lái)獲得更好的訓(xùn)練效果,但層數(shù)的增加會(huì)帶來(lái)很多負(fù)作用,比如overfit、梯度消失、梯度爆炸等。
inception的提出則從另一種角度來(lái)提升訓(xùn)練結(jié)果:能更高效的利用計(jì)算資源,在相同的計(jì)算量下能提取到更多的特征,從而提升訓(xùn)練結(jié)果。
網(wǎng)絡(luò)結(jié)構(gòu)
Inception結(jié)構(gòu)
inception結(jié)構(gòu)的主要貢獻(xiàn)有兩個(gè):
一是使用1x1的卷積來(lái)進(jìn)行升降維;
二是在多個(gè)尺寸上同時(shí)進(jìn)行卷積再聚合。
GoogleNet 的結(jié)構(gòu)主要有Inception模塊構(gòu)成,主要有9個(gè)Incepion模塊,和兩個(gè)卷積模塊構(gòu)成。Inception也有2個(gè)改版。
結(jié)構(gòu)描述
輸入圖像3通道分辨率:224x224x3
9層:圖像輸入后,5個(gè)卷積層,3個(gè)全連接層,1個(gè)輸出層;
(1)C1:64個(gè)conv 7x7,stride=2–> MaxPool 3x3, stride=2 --> 輸出 64個(gè)56x56;
(2)C2:192個(gè)conv 3x3, stride=2 --> MaxPool 3x3, stride=2 --> 輸出 192個(gè)28x28;
(3)inception(3a) :–> 輸出 256個(gè)28x28;
(4)inception(3b) :–> 輸出 480個(gè)28x28;–> MaxPool 3x3, stride=2 --> 輸出 480個(gè)14x14;
(5)inception(4a) :–> 輸出 512個(gè)14x14;
(6)inception(4b) :–> 輸出 512個(gè)14x14;
(7)inception(4c) :–> 輸出 512個(gè)14x14;
(8)inception(4d) :–> 輸出 528個(gè)14x14;
(9)inception(4e) :–> 輸出 832個(gè)14x14;–> MaxPool 3x3, stride=2 --> 輸出 832個(gè)7x7;
(10)inception(5a) :–> 輸出 832個(gè)7x7;
(11)inception(5b) :–> 輸出 1024個(gè)7x7;–> AvgPool 7x1, stride=1 --> 輸出 1024個(gè)1x1;
(12)Dropout(40%):–> 輸出 1024個(gè)1x1;
(13)linear --> 輸出 1000個(gè)1x1;
(14)softmax --> 輸出 1000個(gè)1x1;
整個(gè)GoogleNet 網(wǎng)絡(luò)包含的參數(shù)數(shù)量表。
Pytorch實(shí)現(xiàn)
以下便是使用Pytorch實(shí)現(xiàn)的經(jīng)典網(wǎng)絡(luò)結(jié)構(gòu)GoogleNet
class ConvReLU(nn.Module):def __init__(self, in_channels, out_channels, kernel_size, stride, padding):super().__init__()self.conv = nn.Sequential(nn.Conv2d(in_channels=in_channels, out_channels=out_channels, kernel_size=kernel_size, stride=stride, padding=padding, bias=True),nn.ReLU(inplace=True),) def forward(self, x):return self.conv(x)class InceptionModule(nn.Module):def __init__(self, in_channels, c1x1_out, c3x3_in, c3x3_out, c5x5_in, c5x5_out, pool_proj):super().__init__()self.branch1 = ConvReLU(in_channels=in_channels, out_channels=c1x1_out, kernel_size=1, stride=1, padding=0)self.branch2 = nn.Sequential(ConvReLU(in_channels=in_channels, out_channels=c3x3_in, kernel_size=1, stride=1, padding=0),ConvReLU(in_channels=c3x3_in, out_channels=c3x3_out, kernel_size=3, stride=1, padding=1))self.branch3 = nn.Sequential(ConvReLU(in_channels=in_channels, out_channels=c5x5_in, kernel_size=1, stride=1, padding=0),ConvReLU(in_channels=c5x5_in, out_channels=c5x5_out, kernel_size=5, stride=1, padding=2))self.branch4 = nn.Sequential(nn.MaxPool2d(kernel_size=3, stride=1, padding=1),ConvReLU(in_channels=in_channels, out_channels=pool_proj, kernel_size=1, stride=1, padding=0))def forward(self, x):x1 = self.branch1(x)x2 = self.branch2(x)x3 = self.branch3(x)x4 = self.branch4(x)x = torch.cat([x1, x2, x3, x4], dim=1)return xclass AuxClassifier(nn.Module):def __init__(self, in_channels, n_classes):super().__init__()self.avgpool = nn.AdaptiveAvgPool2d(4)self.conv = ConvReLU(in_channels=in_channels, out_channels=128, kernel_size=1, stride=1, padding=0)self.fc1 = nn.Sequential(nn.Linear(in_features=128*4*4, out_features=1024, bias=True),nn.ReLU(inplace=True))self.dropout = nn.Dropout(p=0.7)self.fc2 = nn.Linear(in_features=1024, out_features=n_classes, bias=True)self.softmax = nn.Softmax(dim=-1)def forward(self, x):b, _, _ ,_ = x.shapex = self.avgpool(x)x = self.conv(x)x = self.fc1(x.view(b, -1))x = self.dropout(x)x = self.fc2(x)x = self.softmax(x)return xclass GooLeNet(nn.Module):def __init__(self, in_channels, n_classes) -> None:super().__init__()self.maxpool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)self.avgpool = nn.AdaptiveAvgPool2d(output_size=1)self.conv1 = nn.Sequential(ConvReLU(in_channels=in_channels, out_channels=64, kernel_size=7, stride=2, padding=3),nn.LocalResponseNorm(size=5, k=2, alpha=1e-4, beta=0.75),)self.conv2 = nn.Sequential(ConvReLU(in_channels=64, out_channels=64, kernel_size=1, stride=1, padding=0),ConvReLU(in_channels=64, out_channels=192, kernel_size=3, stride=1, padding=1),nn.LocalResponseNorm(size=5, k=2, alpha=1e-4, beta=0.75),)self.inception3a = InceptionModule(in_channels=192, c1x1_out=64, c3x3_in=96, c3x3_out=128, c5x5_in=16, c5x5_out=32, pool_proj=32)self.inception3b = InceptionModule(in_channels=256, c1x1_out=128, c3x3_in=128, c3x3_out=192, c5x5_in=32, c5x5_out=96, pool_proj=64)self.inception4a = InceptionModule(in_channels=480, c1x1_out=192, c3x3_in=96, c3x3_out=208, c5x5_in=16, c5x5_out=48, pool_proj=64)self.inception4b = InceptionModule(in_channels=512, c1x1_out=160, c3x3_in=112, c3x3_out=224, c5x5_in=24, c5x5_out=64, pool_proj=64)self.inception4c = InceptionModule(in_channels=512, c1x1_out=128, c3x3_in=128, c3x3_out=256, c5x5_in=24, c5x5_out=64, pool_proj=64)self.inception4d = InceptionModule(in_channels=512, c1x1_out=112, c3x3_in=144, c3x3_out=288, c5x5_in=32, c5x5_out=64, pool_proj=64)self.inception4e = InceptionModule(in_channels=528, c1x1_out=256, c3x3_in=160, c3x3_out=320, c5x5_in=32, c5x5_out=128, pool_proj=128)self.inception5a = InceptionModule(in_channels=832, c1x1_out=256, c3x3_in=160, c3x3_out=320, c5x5_in=32, c5x5_out=128, pool_proj=128)self.inception5b = InceptionModule(in_channels=832, c1x1_out=384, c3x3_in=192, c3x3_out=384, c5x5_in=48, c5x5_out=128, pool_proj=128)self.dropout = nn.Dropout(p=0.4)self.fc = nn.Linear(in_features=1024, out_features=n_classes, bias=True)self.softmax = nn.Softmax(dim=-1)self.aux_classfier1 = AuxClassifier(in_channels=512, n_classes=n_classes)self.aux_classfier2 = AuxClassifier(in_channels=528, n_classes=n_classes)def forward(self, x):b, _, _, _ = x.shapex = self.conv1(x)print('# Conv1 output shape:', x.shape)x = self.maxpool(x)print('# Pool1 output shape:', x.shape)x = self.conv2(x)print('# Conv2 output shape:', x.shape)x = self.maxpool(x)print('# Pool2 output shape:', x.shape)x = self.inception3a(x)print('# Inception3a output shape:', x.shape)x = self.inception3b(x)print('# Inception3b output shape:', x.shape)x = self.maxpool(x)print('# Pool3 output shape:', x.shape)x = self.inception4a(x)print('# Inception4a output shape:', x.shape)aux1 = self.aux_classfier1(x)print('# aux_classifier1 output shape:', aux1.shape)x = self.inception4b(x)print('# Inception4b output shape:', x.shape)x = self.inception4c(x)print('# Inception4c output shape:', x.shape)x = self.inception4d(x)print('# Inception4d output shape:', x.shape)aux2 = self.aux_classfier2(x)print('# aux_classifier2 output shape:', aux2.shape)x = self.inception4e(x)print('# Inception4e output shape:', x.shape)x = self.maxpool(x)print('# Pool4 output shape:', x.shape)x = self.inception5a(x)print('# Inception5a output shape:', x.shape)x = self.inception5b(x)print('# Inception5b output shape:', x.shape)x = self.avgpool(x)print('# Avgpool output shape:', x.shape)x = self.dropout(x.view(b, -1))print('# dropout output shape:', x.shape)x = self.fc(x)print('# FC output shape:', x.shape)x = self.softmax(x)print('# Softmax output shape:', x.shape)return x, aux1, aux2inputs = torch.randn(4, 3, 224, 224)
cnn = GooLeNet(in_channels = 3, n_classes = 1000)
outputs = cnn(inputs)
大家可以和前面的對(duì)照差異,也可以一窺DeepLearning技術(shù)的突破點(diǎn)。
在VGGNet 是一大創(chuàng)舉,DeepMind團(tuán)隊(duì)更聞名的是在圍棋開創(chuàng)一片天地,AlphaGo風(fēng)靡一時(shí),把人工智能推向又一個(gè)高潮,CNN網(wǎng)絡(luò)引領(lǐng)的深度學(xué)習(xí)蓬勃發(fā)展,造就人工智能技術(shù)革命的起點(diǎn)。
覺(jué)得有用 收藏 收藏 收藏
點(diǎn)個(gè)贊 點(diǎn)個(gè)贊 點(diǎn)個(gè)贊
End
GPT專欄文章:
GPT實(shí)戰(zhàn)系列-實(shí)戰(zhàn)Qwen通義千問(wèn)在Cuda 12+24G部署方案_通義千問(wèn) ptuning-CSDN博客
GPT實(shí)戰(zhàn)系列-ChatGLM3本地部署CUDA11+1080Ti+顯卡24G實(shí)戰(zhàn)方案
GPT實(shí)戰(zhàn)系列-Baichuan2本地化部署實(shí)戰(zhàn)方案
GPT實(shí)戰(zhàn)系列-讓CodeGeeX2幫你寫代碼和注釋_codegeex 中文-CSDN博客
GPT實(shí)戰(zhàn)系列-ChatGLM3管理工具的API接口_chatglm3 api文檔-CSDN博客
GPT實(shí)戰(zhàn)系列-大話LLM大模型訓(xùn)練-CSDN博客
GPT實(shí)戰(zhàn)系列-LangChain + ChatGLM3構(gòu)建天氣查詢助手
GPT實(shí)戰(zhàn)系列-大模型為我所用之借用ChatGLM3構(gòu)建查詢助手
GPT實(shí)戰(zhàn)系列-P-Tuning本地化訓(xùn)練ChatGLM2等LLM模型,到底做了什么?(二)
GPT實(shí)戰(zhàn)系列-P-Tuning本地化訓(xùn)練ChatGLM2等LLM模型,到底做了什么?(一)
GPT實(shí)戰(zhàn)系列-ChatGLM2模型的微調(diào)訓(xùn)練參數(shù)解讀
GPT實(shí)戰(zhàn)系列-如何用自己數(shù)據(jù)微調(diào)ChatGLM2模型訓(xùn)練
GPT實(shí)戰(zhàn)系列-ChatGLM2部署Ubuntu+Cuda11+顯存24G實(shí)戰(zhàn)方案
GPT實(shí)戰(zhàn)系列-Baichuan2等大模型的計(jì)算精度與量化
GPT實(shí)戰(zhàn)系列-GPT訓(xùn)練的Pretraining,SFT,Reward Modeling,RLHF
GPT實(shí)戰(zhàn)系列-探究GPT等大模型的文本生成-CSDN博客