• pytorch-Alexnet 网络


    Alexnet网络结构, 相比于LeNet,Alexnet加入了激活层Relu, 以及dropout层

    第一层网络结构: 11x11x3x96, 步长为4, padding=2 

    第二层网络结构: 5x5x96x256, 步长为1, padding=1

    第三层网络结构: 3x3x256x384,步长为1, padding=1

    第四层网络结构: 3x3x256x384,步长为1,padding=1 

    第五层网络结构: 3x3x384x384, 步长为1,padding=1 

    第六层网络结构: 3x3x384x256, 步长为1, padding=1

    第七层网络结构: 进行维度变化, 进行dropout操作, 进行(256*6*6, 4096)全连接操作

    第八层:进行dropout操作,进行全连接操作(4096, 4096) 

    第九层: 输出层的操作, 进行全连接(4096, num_classes)

    from torch import nn
    
    
    class AlexNet(nn.Module):
        def __init__(self, num_classes):
            super(AlexNet, self).__init__()
            self.feature = nn.Sequential(
                nn.Conv2d(3, 96, kernel_size=11, stride=4, padding=2),
                nn.ReLU(inplace=True),
                nn.MaxPool2d(kernel_size=3, stride=2),
                nn.Conv2d(96, 256, kernel_size=5, padding=2),
                nn.ReLU(inplace=True),
                nn.MaxPool2d(kernel_size=3, stride=2),
                nn.Conv2d(256, 384, kernel_size=3, padding=1),
                nn.ReLU(inplace=True),
                nn.Conv2d(384, 384, kernel_size=3, padding=1),
                nn.ReLU(inplace=True),
                nn.Conv2d(384, 256, kernel_size=3, padding=1),
                nn.ReLU(inplace=True),
                nn.MaxPool2d(kernel_size=3, stride=2),)
            self.classifier = nn.Sequential(
                nn.Dropout(),
                nn.Linear(256 * 6 * 6, 4096),
                nn.ReLU(inplace=True),
                nn.Dropout(),
                nn.Linear(4096, 4096),
                nn.ReLU(inplace=True),
                nn.Linear(4096, num_classes),
            )
    
        def forward(self, x):
            x = self.feature(x)
            x = self.classifier(x)
            return x
        
  • 相关阅读:
    C# Redis实战(四)
    C# Redis实战(三)
    C# Redis实战(二)
    C# Redis实战(一)
    C#连接内存数据库redis【1、Redis存读取数据】
    C#连接内存数据库redis【1、安装配置】
    c#根据配置文件反射
    内存数据库:Redis与Memcached的区别
    内存数据库:memcached与redis技术的对比试验
    【转】【涨姿势】支付宝怎么做风险控制?
  • 原文地址:https://www.cnblogs.com/my-love-is-python/p/11729287.html
Copyright © 2020-2023  润新知