深度学习-解读GoogleNet深度学习网络

深度学习-解读GoogleNet深度学习网络

深度学习中,经典网络引领一波又一波的技术革命,从LetNet到当前最火的GPT所用的Transformer,它们把AI技术不断推向高潮。2012年AlexNet大放异彩,它把深度学习技术引领第一个高峰,打开人们的视野。

用pytorch构建CNN经典网络模型GoogleNet,又称为Inception V1 ,还可以用数据进行训练模型,得到一个优化的模型。

深度学习

深度学习-回顾经典AlexNet网络:山高我为峰-CSDN博客

深度学习-CNN网络改进版LetNet5-CSDN博客

深度学习-回顾CNN经典网络LetNet-CSDN博客

GPT实战系列-如何用自己数据微调ChatGLM2模型训练_pytorch 训练chatglm2 模型-CSDN博客

Caffe笔记:python图像识别与分类_python 怎么识别 caffe-CSDN博客

深度学习-Pytorch同时使用Numpy和Tensors各自特效-CSDN博客

深度学习-Pytorch运算的基本数据类型_pytorch支持的训练数据类型-CSDN博客

深度学习-Pytorch如何保存和加载模型

深度学习-Pytorch如何构建和训练模型-CSDN博客

深度学习-Pytorch数据集构造和分批加载-CSDN博客

Python Faster R-CNN 安装配置记录_attributeerror: has no attribute 'smooth_l1_loss-CSDN博客

经典算法-遗传算法的python实现

经典算法-模拟退火算法的python实现

经典算法-粒子群算法的python实现-CSDN博客

GoogleNet概述

GoogLeNet是2014年Christian Szegedy提出的一种全新的深度学习结构,和VGGNet同一年诞生,获得2014年ILSVRC竞赛的第一名。

在这之前的AlexNet、VGG等结构都是通过增大网络的深度(层数)来获得更好的训练效果,但层数的增加会带来很多负作用,比如overfit、梯度消失、梯度爆炸等。

inception的提出则从另一种角度来提升训练结果:能更高效的利用计算资源,在相同的计算量下能提取到更多的特征,从而提升训练结果。

网络结构

Inception结构

inception结构的主要贡献有两个:

一是使用1x1的卷积来进行升降维;

二是在多个尺寸上同时进行卷积再聚合。

在这里插入图片描述

GoogleNet 的结构主要有Inception模块构成,主要有9个Incepion模块,和两个卷积模块构成。Inception也有2个改版。

结构描述

输入图像3通道分辨率:224x224x3

9层:图像输入后,5个卷积层,3个全连接层,1个输出层;

(1)C1:64个conv 7x7,stride=2–> MaxPool 3x3, stride=2 --> 输出 64个56x56;

(2)C2:192个conv 3x3, stride=2 --> MaxPool 3x3, stride=2 --> 输出 192个28x28;

(3)inception(3a) :–> 输出 256个28x28;

(4)inception(3b) :–> 输出 480个28x28;–> MaxPool 3x3, stride=2 --> 输出 480个14x14;

(5)inception(4a) :–> 输出 512个14x14;

(6)inception(4b) :–> 输出 512个14x14;

(7)inception(4c) :–> 输出 512个14x14;

(8)inception(4d) :–> 输出 528个14x14;

(9)inception(4e) :–> 输出 832个14x14;–> MaxPool 3x3, stride=2 --> 输出 832个7x7;

(10)inception(5a) :–> 输出 832个7x7;

(11)inception(5b) :–> 输出 1024个7x7;–> AvgPool 7x1, stride=1 --> 输出 1024个1x1;

(12)Dropout(40%):–> 输出 1024个1x1;

(13)linear --> 输出 1000个1x1;

(14)softmax --> 输出 1000个1x1;

整个GoogleNet 网络包含的参数数量表。

Pytorch实现

以下便是使用Pytorch实现的经典网络结构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)

在这里插入图片描述

大家可以和前面的对照差异,也可以一窥DeepLearning技术的突破点。

在VGGNet 是一大创举,DeepMind团队更闻名的是在围棋开创一片天地,AlphaGo风靡一时,把人工智能推向又一个高潮,CNN网络引领的深度学习蓬勃发展,造就人工智能技术革命的起点。

觉得有用 收藏 收藏 收藏

点个赞 点个赞 点个赞

End

GPT专栏文章:

GPT实战系列-实战Qwen通义千问在Cuda 12+24G部署方案_通义千问 ptuning-CSDN博客

GPT实战系列-ChatGLM3本地部署CUDA11+1080Ti+显卡24G实战方案

GPT实战系列-Baichuan2本地化部署实战方案

GPT实战系列-让CodeGeeX2帮你写代码和注释_codegeex 中文-CSDN博客

GPT实战系列-ChatGLM3管理工具的API接口_chatglm3 api文档-CSDN博客

GPT实战系列-大话LLM大模型训练-CSDN博客

GPT实战系列-LangChain + ChatGLM3构建天气查询助手

GPT实战系列-大模型为我所用之借用ChatGLM3构建查询助手

GPT实战系列-P-Tuning本地化训练ChatGLM2等LLM模型,到底做了什么?(二)

GPT实战系列-P-Tuning本地化训练ChatGLM2等LLM模型,到底做了什么?(一)

GPT实战系列-ChatGLM2模型的微调训练参数解读

GPT实战系列-如何用自己数据微调ChatGLM2模型训练

GPT实战系列-ChatGLM2部署Ubuntu+Cuda11+显存24G实战方案

GPT实战系列-Baichuan2等大模型的计算精度与量化

GPT实战系列-GPT训练的Pretraining,SFT,Reward Modeling,RLHF

GPT实战系列-探究GPT等大模型的文本生成-CSDN博客

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

如若内容造成侵权/违法违规/事实不符,请联系瞎胡闹网进行投诉反馈,一经查实,立即删除!

相关文章

【GitHub】使用git链接下载很慢?试试服务器配置SSH,起飞

参考文献 保姆级教学,教你用配置SSH拉取github代码 CentOS ssh -T gitgithub.comgit config --global user.name "learnore" git config --global user.email "15200831505163.com"cd /root/.ssh vim id_rsa.pubGitHub Settings 结果 下载速…

部署一个本地的ChatGPT(Ollama)

一 下载Ollama Ollama下载地址:https://ollama.com/download 下载完后 二 安装运行 双击下载好的OllamaSetup.exe开发 安装Ollama: 安装完成后,多了一个Ollama的菜单如下图 : Ollama安装好默认是配置开机运行,如果没有运行可以在…

Java安全 CC链2分析

Java安全 CC链2分析 cc链2介绍前置知识环境配置类加载机制 触发流程cc链2POCcc链2分析 cc链2介绍 CC2链适用于Apache common collection 4.0版本,由于该版本对AnnotationInvocationHandler类的readObject方法进行了修复,导致cc链1无法使用,故…

中文编程入门(Lua5.4.6中文版)第四章 Lua 流程控制

Lua 编程语言中的流程控制就像推塔游戏战场上的智谋队长,挥舞着策略之剑,根据战场局势(条件语句)的演变,精准地指挥团队成员执行或猛攻或防守的操作。在这场代码与逻辑的对战中,当判定条件亮起 “true” 的…

【Java】List, Set, Queue, Map 区别?

目录 List, Set, Queue, Map 区别? Collection和Collections List ArrayList 和 Array区别? ArrayList与LinkedList区别? ArrayList 能添加null吗? ArrayList 插入和删除时间复杂度? LinkedList 插入和删除时间复杂度&…

Javaweb day17 day18 day19

mysql-DDL 数据库操作 写法 客户端工具 (也可以使用idea) 表 写法 约束 数据类型 案例 写法 表的查询修改删除 写法 删除

抖去推无人直播+矩阵托管+AI文案撰写一体化工具如何开发搭建

一、 开发和搭建抖去推无人直播矩阵托管AI文案撰写一体化工具需要以下步骤: 确定功能需求:确定抖去推无人直播、矩阵托管和AI文案撰写的具体功能需求,如直播推流、直播管理、托管服务、AI文案生成等。 技术选型:选择适合开发该工…

ChatGPT编程—实现小工具软件(文件查找和筛选)

ChatGPT编程—实现小工具软件(文件查找和筛选) 今天借助[小蜜蜂AI][https://zglg.work]网站的ChatGPT编程实现一个功能:根据特定需求结合通配符和其他条件来进行文件查找和筛选。在这个例子中,我们将创建一个函数find_files,它接受用户输入的…

Qt 写一个邮件发送程序

最近在完成一个邮箱代替的告警功能&#xff0c;写了一个邮件发送的demo 以下为代码&#xff1a; #ifndef MAINWINDOW_H #define MAINWINDOW_H#include <QMainWindow> #include<QTcpSocket> namespace Ui { class MainWindow; }class MainWindow : public QMainWin…

RoketMQ主从搭建

vim /etc/hosts# IP与域名映射&#xff0c;端口看自己的#nameserver 192.168.126.132 rocketmq-nameserver1 192.168.126.133 rocketmq-nameserver2# 注意主从节点不在同一个主机上 #broker 192.168.126.132 rocketmq-master1 192.168.126.133 rocketmq-master2#broker 192.168…

LeetCode 2684.矩阵中移动的最大次数:一列一列处理,只记能到哪行(BFS)

【LetMeFly】2684.矩阵中移动的最大次数&#xff1a;一列一列处理&#xff0c;只记能到哪行(BFS) 力扣题目链接&#xff1a;https://leetcode.cn/problems/maximum-number-of-moves-in-a-grid/ 给你一个下标从 0 开始、大小为 m x n 的矩阵 grid &#xff0c;矩阵由若干 正 整…

SQLiteC/C++接口详细介绍之sqlite3类(十五)

返回目录&#xff1a;SQLite—免费开源数据库系列文章目录 上一篇&#xff1a;SQLiteC/C接口详细介绍之sqlite3类&#xff08;十四&#xff09; 下一篇&#xff1a;SQLiteC/C接口详细介绍之sqlite3类&#xff08;十六&#xff09; 47.sqlite3_set_authorizer 用法&#xff…

会员项目定价卡css3特效

会员项目定价卡css3特效&#xff0c;源码由HTMLCSSJS组成&#xff0c;记事本打开源码文件可以进行内容文字之类的修改&#xff0c;双击html文件可以本地运行效果&#xff0c;也可以上传到服务器里面 下载地址 会员项目定价卡css3特效代码

(一)、机器人时间同步方案分析

1、是否有必要进行时间同步 目前的自动驾驶系统包括 感知、定位、决策规划、控制 等模块&#xff0c;这些模块的正常运行需要依靠各种不同类型的传感器数据的准确 融合。尤其是激光雷达与相机这两种传感器在感、知定位模块中起着至关重要的作用。机械式旋转扫描激光雷达本身较低…

2024最新手赚手机软件APP下载排行网站源码及应用商店源码

这是一款简洁蓝色的手机软件下载应用排行、平台和最新发布网站&#xff0c;采用响应式织梦模板。主要包括主页、APP列表页、APP详情介绍页、新闻资讯列表、新闻详情页、关于我们等模块页面。 源码下载&#xff1a;https://download.csdn.net/download/m0_66047725/88898956 更…

数字IC实践项目(9)—SNN加速器的设计和实现(tiny_ODIN)

数字IC实践项目&#xff08;9&#xff09;—基于Verilog的SNN加速器 写在前面的话项目整体框图完整电路框图 项目简介和学习目的软件环境要求 Wave&CoverageTiming&#xff0c;Area & Power总结 写在前面的话 项目介绍&#xff1a; SNN硬件加速器是一种专为脉冲神经网…

用 Visual Studio 调试器中查看内存中图像

返回目录&#xff1a;OpenCV系列文章目录&#xff08;持续更新中......&#xff09; 前一篇&#xff1a;OpenCV4.9.0在windows系统下的安装 后一篇&#xff1a; ​警告 本教程可以包含过时的信息。 Image Watch 是 Microsoft Visual Studio 的插件&#xff0c;可用于在调…

网络安全——关于防火墙

网络安全防火墙是很重要的部分&#xff0c;关于防火墙我们要知道&#xff0c;他默认所有流量都是黑名单&#xff0c;只有开启允许通过才可以。 我们通过一个实验来学防火墙命令。 防火墙要登录才能使用&#xff0c;用户名是admin,默认密码是Admin123&#xff0c;在第一次登录…

【视频异常检测】Diversity-Measurable Anomaly Detection 论文阅读

Diversity-Measurable Anomaly Detection 论文阅读 Abstract1. Introduction2. Related Work3. Diversity-Measurable Anomaly Detection3.1. The framework3.2. Information compression module3.3. Pyramid deformation module3.4. Foreground-background selection3.5. Trai…

鸿蒙Harmony应用开发—ArkTS声明式开发(容器组件:Stack)

堆叠容器&#xff0c;子组件按照顺序依次入栈&#xff0c;后一个子组件覆盖前一个子组件。 说明&#xff1a; 该组件从API Version 7开始支持。后续版本如有新增内容&#xff0c;则采用上角标单独标记该内容的起始版本。 子组件 可以包含子组件。 接口 Stack(value?: { ali…