vgg16网络改深度可分离卷积

2023-05-16

原网络

class CNN0(nn.Module):
 
    def __init__(self,imageHeight,nChannel):
        super(CNN0,self).__init__()
        assert imageHeight % 32 == 0,'image Height has to be a multiple of 32'
 
        self.conv0 = nn.Conv2d(in_channels=nChannel,out_channels=64,kernel_size=3,stride=1,padding=1)
        self.relu0 = nn.ReLU(inplace=True)
        self.pool0 = nn.MaxPool2d(kernel_size=2,stride=2)
 
        self.conv1 = nn.Conv2d(in_channels=64,out_channels=128,kernel_size=3,stride=1,padding=1)
        self.relu1 = nn.ReLU(inplace=True)
        self.pool1 = nn.MaxPool2d(kernel_size=2,stride=2)
 
        self.conv2 = nn.Conv2d(in_channels=128,out_channels=256,kernel_size=3,stride=1,padding=1)
        self.batchNorm2 = nn.BatchNorm2d(256)
        self.relu2 = nn.ReLU(inplace=True)
 
        self.conv3 = nn.Conv2d(in_channels=256, out_channels=256, kernel_size=3, stride=1, padding=1)
        self.relu3 = nn.ReLU(inplace=True)
        self.pool3 = nn.MaxPool2d(kernel_size=(2,2),stride=(2,1),padding=(0,1))
 
        self.conv4 = nn.Conv2d(in_channels=256, out_channels=512, kernel_size=3, stride=1, padding=1)
        self.batchNorm4 = nn.BatchNorm2d(512)
        self.relu4 = nn.ReLU(inplace=True)
 
        self.conv5 = nn.Conv2d(in_channels=512, out_channels=512, kernel_size=3, stride=1, padding=1)
        self.relu5 = nn.ReLU(inplace=True)
        self.pool5 = nn.MaxPool2d(kernel_size=(2,2),stride=(2,1),padding=(0,1))
 
        self.conv6 = nn.Conv2d(in_channels=512, out_channels=512, kernel_size=2, stride=1, padding=0)
        self.batchNorm6 = nn.BatchNorm2d(512)
        self.relu6= nn.ReLU(inplace=True)
 
    def forward(self,input):
        conv0 = self.conv0(input)
        relu0 = self.relu0(conv0)
        pool0 = self.pool0(relu0)
        print(pool0.size())
 
        conv1 = self.conv1(pool0)
        relu1 = self.relu1(conv1)
        pool1 = self.pool1(relu1)
        print(pool1.size())
 
        conv2 = self.conv2(pool1)
        batchNormal2 = self.batchNorm2(conv2)
        relu2 = self.relu2(batchNormal2)
        print(relu2.size())
 
        conv3 = self.conv3(relu2)
        relu3 = self.relu3(conv3)
        pool3 = self.pool3(relu3)
        print(pool3.size())
 
        conv4 = self.conv4(pool3)
        batchNormal4 = self.batchNorm4(conv4)
        relu4 = self.relu4(batchNormal4)
        print(relu4.size())
 
        conv5 = self.conv5(relu4)
        relu5 = self.relu5(conv5)
        pool5 = self.pool5(relu5)
        print(pool5.size())
 
        conv6 = self.conv6(pool5)
        batchNormal6 = self.batchNorm6(conv6)
        relu6 = self.relu6(batchNormal6)
        print(relu6.size())
 
        return relu6

深度可分离卷积

class CNN(nn.Module):
 
    def __init__(self,imageHeight,nChannel):
        super(CNN,self).__init__()
        assert imageHeight % 32 == 0,'image Height has to be a multiple of 32'
 
        self.depth_conv0 = nn.Conv2d(in_channels=nChannel,out_channels=nChannel,kernel_size=3,stride=1,padding=1,groups=nChannel)
        self.point_conv0 = nn.Conv2d(in_channels=nChannel,out_channels=64,kernel_size=1,stride=1,padding=0,groups=1)
        self.relu0 = nn.ReLU(inplace=True)
        self.pool0 = nn.MaxPool2d(kernel_size=2,stride=2)
 
        self.depth_conv1 = nn.Conv2d(in_channels=64,out_channels=64,kernel_size=3,stride=1,padding=1,groups=64)
        self.point_conv1 = nn.Conv2d(in_channels=64,out_channels=128,kernel_size=1,stride=1,padding=0,groups=1)
        self.relu1 = nn.ReLU(inplace=True)
        self.pool1 = nn.MaxPool2d(kernel_size=2,stride=2)
 
        self.depth_conv2 = nn.Conv2d(in_channels=128,out_channels=128,kernel_size=3,stride=1,padding=1,groups=128)
        self.point_conv2 = nn.Conv2d(in_channels=128,out_channels=256,kernel_size=1,stride=1,padding=0,groups=1)
        self.batchNorm2 = nn.BatchNorm2d(256)
        self.relu2 = nn.ReLU(inplace=True)
 
        self.depth_conv3 = nn.Conv2d(in_channels=256, out_channels=256, kernel_size=3, stride=1, padding=1, groups=256)
        self.point_conv3 = nn.Conv2d(in_channels=256, out_channels=256, kernel_size=1, stride=1, padding=0, groups=1)
        self.relu3 = nn.ReLU(inplace=True)
        self.pool3 = nn.MaxPool2d(kernel_size=(2,2),stride=(2,1),padding=(0,1))
 
        self.depth_conv4 = nn.Conv2d(in_channels=256, out_channels=256, kernel_size=3, stride=1, padding=1, groups=256)
        self.point_conv4 = nn.Conv2d(in_channels=256, out_channels=512, kernel_size=1, stride=1, padding=0, groups=1)
        self.batchNorm4 = nn.BatchNorm2d(512)
        self.relu4 = nn.ReLU(inplace=True)
 
        self.depth_conv5 = nn.Conv2d(in_channels=512, out_channels=512, kernel_size=3, stride=1, padding=1, groups=512)
        self.point_conv5 = nn.Conv2d(in_channels=512, out_channels=512, kernel_size=1, stride=1, padding=0, groups=1)
        self.relu5 = nn.ReLU(inplace=True)
        self.pool5 = nn.MaxPool2d(kernel_size=(2,2),stride=(2,1),padding=(0,1))
 
        #self.conv6 = nn.Conv2d(in_channels=512, out_channels=512, kernel_size=2, stride=1, padding=0)
        self.depth_conv6 = nn.Conv2d(in_channels=512, out_channels=512, kernel_size=2, stride=1, padding=0, groups=512)
        self.point_conv6 = nn.Conv2d(in_channels=512, out_channels=512, kernel_size=1, stride=1, padding=0, groups=1)
        self.batchNorm6 = nn.BatchNorm2d(512)
        self.relu6= nn.ReLU(inplace=True)
 
    def forward(self,input):
        depth0 = self.depth_conv0(input)
        point0 = self.point_conv0(depth0)
        relu0 = self.relu0(point0)
        pool0 = self.pool0(relu0)
 
        depth1 = self.depth_conv1(pool0)
        point1 = self.point_conv1(depth1)
        relu1 = self.relu1(point1)
        pool1 = self.pool1(relu1)
 
        depth2 = self.depth_conv2(pool1)
        point2 = self.point_conv2(depth2)
        batchNormal2 = self.batchNorm2(point2)
        relu2 = self.relu2(batchNormal2)
 
        depth3 = self.depth_conv3(relu2)
        point3 = self.point_conv3(depth3)
        relu3 = self.relu3(point3)
        pool3 = self.pool3(relu3)
 
        depth4 = self.depth_conv4(pool3)
        point4 = self.point_conv4(depth4)
        batchNormal4 = self.batchNorm4(point4)
        relu4 = self.relu4(batchNormal4)
 
        depth5 = self.depth_conv5(relu4)
        point5 = self.point_conv5(depth5)
        relu5 = self.relu5(point5)
        pool5 = self.pool5(relu5)
 
        depth6 = self.depth_conv6(pool5)
        point6 = self.point_conv6(depth6)
        batchNormal6 = self.batchNorm6(point6)
        relu6 = self.relu6(batchNormal6)
 
        return relu6
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

vgg16网络改深度可分离卷积 的相关文章

  • 树莓派4B内核打RT-preempt实时补丁的实现

    硬件环境 xff1a 树莓派4B 操作系统 xff1a 树莓派版Ubuntu server 20 04 LTS xff08 64bit xff09 1 依赖环境的安装 运行如下命令 xff1a span class token functi
  • RT-Preempt笔记

    基于Zynq平台的Linux实时性研究及在数据采集中的应用 马啸 嵌入式实时系统研究现状 实时操作系统专门用于在时间约束条件下运行时间关键的应用程序 用于操作处理实时任务所需的最坏情况执行时间 xff08 Worst Case Execut
  • Mac上vmware fusion装的ubuntu不能与主机复制粘贴的问题

    解决方法一 xff1a 安装vmware tools 依次点击 xff1a 虚拟机 gt 安装vmware tools 会在ubuntu桌面上出现vmware tools xff0c 双击打开 解压tar gz包 xff0c 执行解压命令t
  • ceph的一些优化

    最近一直在忙着搞Ceph存储的优化和测试 xff0c 看了各种资料 xff0c 但是好像没有一篇文章把其中的方法论交代清楚 xff0c 所以呢想在这里进行一下总结 xff0c 很多内容并不是我原创 xff0c 只是做一个总结 如果其中有任何
  • Ubuntu 20.04使用qemu搭建ARM64 Linux系统

    1 安装所需依赖 span class token function sudo span span class token function apt get span span class token function install sp
  • GCC 编译选项总结

    c 只激活预处理 编译 和汇编 也就是他只把程序做成obj文件 例子用法 gcc span class token operator span c hello span class token punctuation span c 他将生成
  • 常见排序算法 Python实现

    冒泡排序 span class token keyword def span span class token function bubbleSort span span class token punctuation span lst s
  • GCC 编译优化等级

    参考资料 xff1a Using the GNU Compiler Collection 打开优化标志会使编译器尝试以牺牲编译时间和调试程序的能力为代价来提高性能和 或代码大小 根据目标和 GCC 的配置方式 xff0c 在每个 O 级别启
  • 树莓派4B开机自动发微信报告ip地址

    方法的实现基本基于博主虚宇宸轩的 实现 树莓派开机自动向微信发消息报告ip地址 xff08 无第三方代理 xff09 xff0c 具体原理和操作过程 xff0c 请参考该博主的文章 xff0c 写得很详细 xff0c 原理解释的也很清楚 本
  • 解决arm-none-eabi-gcc交叉编译helloworld程序segmentation fault 错误

    目标 xff1a 在x86 64主机上 windows 10或ubuntu 20 04 上交叉编译arm架构的helloworld程序 xff0c 然后通过scp将编译完的可执行文件传给树莓派4B xff0c 在树莓派上执行该程序 xff0
  • 中断方式及DMA工作详解

    一 轮询方式 对I O设备的程序轮询的方式 xff0c 是早期的计算机系统对I O设备的一种管理方式 它定时对各种设备轮流询问一遍有无处理要求 轮流询问之后 xff0c 有要求的 xff0c 则加以处理 在处理I O设备的要求之后 xff0
  • 构成帧的方法

    组帧 组帧的原因是为了在出错的时候只需要重发出错的帧 xff0c 而不需要重发全部数据 xff0c 从而提高效率 为了能让接收方正确地接收并检查所传输的帧 xff0c 发送方必须依据一定的规则把网络层传下来的分组封装成帧 这个动作称为组帧
  • AUTOWARE下底盘CAN通讯实现

    无人驾驶系列 autoware与底盘CAN通讯实现 本文介绍在使用autoware时 xff0c 如何将autoware发送的消息传输给底盘 xff0c 实现对线控底盘的控制 准备工作 xff1a 1 系统具备ROS和autoware 2
  • Boost库安装与使用

    Boost 库很不错 xff0c 所以我今天就安了它一下下 Boost 库不是 C 43 43 标准库的一部分 xff08 据说在下一版本的 C 43 43 标准会采纳它 xff09 xff0c 但它有一些标准库所没有的很有用的一些功能 x
  • ROS Ubuntu20.04多版本opencv运行及bug解决

    ubuntu系统装有多个版本opencv使用方法及可能出现的问题 xff1a 单opencv版本时使用命令 xff1a find package OpenCV 3 2 REQUIRED 其默认是在user local 目录下安装的openc
  • UDP编程

    一切以包裹为中心 xff0c 字节数组为核心 一 UDP的基本步骤 xff1a 1 xff09 发送端 package com sxt udp import java net DatagramPacket import java net D
  • LWIP之lwip_select函数使用

    本测试基于lwip2 1 2 参考了CSDN博主 64 则强 的文章 原文链接 xff1a https blog csdn net baidu 39191253 article details 127630186 部分地方做了修改 xff0
  • 直流无刷电机的调试与代码开源(配套资源)

    本周对手头的一款大疆M3508直流无刷电机调试的相关内容进行整理及个人的代码进行分享 一 M3508直流无刷电机 直流无刷电机的工作原理此处不做阐述 xff0c 相关资料也易查询 1 1电机结构与连接样式图 1 2电机参数 具体不多加阐述
  • Linux网络编程——UDP编程

    文章目录 前言一 udp编程相关函数1 socket函数2 bind函数3 sendto函数4 recvfrom函数5 close函数 二 实际案例总结 前言 1 UDP通信协议 xff0c 服务器端和客户端无需建立连接 xff0c 只需要
  • c++ vector用法 入门必看 超详细

    1 vector的作用 vector是最常用的容器之一 xff0c 功能十分强大 xff0c 可以储存 管理各种类型的数据 在很多情况下可以用来代替功能比较局限的普通数组 xff0c 因为我们知道 xff0c 普通数组只能实现一对一的映射而

随机推荐