当前位置:网站首页>Alexnet model
Alexnet model
2022-04-23 14:46:00 【Recurss】
import torch.nn as nn
import torch
class AlexNet(nn.Module):
def __init__(self, num_classes=1000, init_weights=False):
super(AlexNet, self).__init__()
self.features = nn.Sequential(
nn.Conv2d(3, 48, kernel_size=11, stride=4, padding=2), # input[3, 224, 224] output[48, 55, 55]
nn.ReLU(inplace=True),
nn.MaxPool2d(kernel_size=3, stride=2), # output[48, 27, 27]
nn.Conv2d(48, 128, kernel_size=5, padding=2), # output[128, 27, 27]
nn.ReLU(inplace=True),
nn.MaxPool2d(kernel_size=3, stride=2), # output[128, 13, 13]
nn.Conv2d(128, 192, kernel_size=3, padding=1), # output[192, 13, 13]
nn.ReLU(inplace=True),
nn.Tanh(),
nn.Conv2d(192, 192, kernel_size=3, padding=1), # output[192, 13, 13]
nn.ReLU(inplace=True),
nn.Conv2d(192, 128, kernel_size=3, padding=1), # output[128, 13, 13]
nn.ReLU(inplace=True),
nn.MaxPool2d(kernel_size=3, stride=2), # output[128, 6, 6]
)
self.classifier = nn.Sequential(
nn.Dropout(p=0.5),
nn.Linear(128 * 6 * 6, 2048),
nn.ReLU(inplace=True),
nn.Dropout(p=0.5),
nn.Linear(2048, 2048),
nn.ReLU(inplace=True),
nn.Linear(2048, num_classes),
)
if init_weights:
self._initialize_weights()
def forward(self, x):
x = self.features(x)
x = torch.flatten(x, start_dim=1)
x = self.classifier(x)
return x
def _initialize_weights(self):
for m in self.modules():
if isinstance(m, nn.Conv2d):
nn.init.kaiming_normal_(m.weight, mode='fan_out', nonlinearity='relu')
if m.bias is not None:
nn.init.constant_(m.bias, 0)
elif isinstance(m, nn.Linear):
nn.init.normal_(m.weight, 0, 0.01)
nn.init.constant_(m.bias, 0)
版权声明
本文为[Recurss]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Recursions/article/details/124361770
边栏推荐
- Some little records~
- Design of single chip microcomputer Proteus for temperature and humidity monitoring and alarm system of SHT11 sensor (with simulation + paper + program, etc.)
- Swift:Entry of program、Swift调用OC、@_silgen_name 、 OC 调用Swift、dynamic、String、Substring
- 【NLP】HMM隐马尔可夫+维特比分词
- [jz46 translate numbers into strings]
- Detailed explanation of SAR command
- OpenFaaS实战之四:模板操作(template)
- OC to swift conditional compilation, marking, macro, log, version detection, expiration prompt
- I thought I could lie down and enter Huawei, but I was confused when I received JD / didi / iqiyi offers one after another
- 想要成为架构师?夯实基础最重要
猜你喜欢

电容

51 MCU flowers, farmland automatic irrigation system development, proteus simulation, schematic diagram and C code
![[detailed explanation of factory mode] factory method mode](/img/56/04fa84d0b5f30e759854a39afacff2.png)
[detailed explanation of factory mode] factory method mode

MCU function signal generator, output four kinds of waveforms, adjustable frequency, schematic diagram, simulation and C program

基于单片机的DS18B20的数字温度监控报警系统设计【LCD1602显示+Proteus仿真+C程序+论文+按键设置等】

A good tool: aardio

The art of automation

8.4 循环神经网络从零实现

8.5 循环神经网络简洁实现

Do (local scope), initializer, memory conflict, swift pointer, inout, unsafepointer, unsafebitcast, success
随机推荐
Want to be an architect? Tamping the foundation is the most important
Outsourcing for four years, abandoned
Multisim Simulation Design of DC adjustable regulated power supply of LM317 (with simulation + paper + reference)
51 Single Chip Microcomputer Design of traffic light system (with Proteus simulation, C program, schematic diagram, PCB, thesis and other complete data)
go基础 反射
ArrayList collection basic usage
OpenFaaS实战之四:模板操作(template)
Parameter stack pressing problem of C language in structure parameter transmission
MCU function signal generator, output four kinds of waveforms, adjustable frequency, schematic diagram, simulation and C program
Arduino for esp8266串口功能简介
Four ways of SSH restricting login
【NLP】HMM隐马尔可夫+维特比分词
《JVM系列》 第七章 -- 字节码执行引擎
Epoll's et, lt working mode -- example program
1 minute to understand the execution process and permanently master the for cycle (with for cycle cases)
51 MCU flowers, farmland automatic irrigation system development, proteus simulation, schematic diagram and C code
拼接hql时,新增字段没有出现在构造方法中
ASEMI整流模块MDQ100-16在智能开关电源中的作用
三、梯度下降求解最小θ
One of the advanced applications of I / O reuse: non blocking connect -- implemented using select (or poll)