pytorch - 为什么我在 CIFAR10 上训练的 AlexNet 不起作用?
问题描述
我正在尝试实现 AlexNet 并在 CIFAR10 上进行训练。然而,损失并没有减少。你能告诉我任何问题吗?
class Alexnet(nn.Module):
def __init__(self):
super().__init__()
self.conv1=nn.Sequential(nn.Conv2d(3,64,3,2,1),nn.ReLU(),nn.MaxPool2d(2))
self.conv2=nn.Sequential(nn.Conv2d(64,192,3,1,padding=2),nn.MaxPool2d(2))
self.conv3=nn.Sequential(nn.Conv2d(192,384,3,1,padding=1),nn.ReLU())
self.conv4=nn.Sequential(nn.Conv2d(384,256,3,1,padding=1),nn.ReLU())
self.conv5=nn.Sequential(nn.Conv2d(256,256,3,1,padding=1),nn.ReLU(),nn.MaxPool2d(2))
self.dropout=nn.Dropout(0.3)
self.fc1=nn.Sequential(nn.Flatten(),nn.Linear(256*2*2,4096),nn.ReLU())
self.fc2=nn.Sequential(nn.Linear(4096,4096),nn.ReLU())
self.fc3=nn.Sequential(nn.Linear(4096,10),nn.ReLU())
def forward(self,x):
x=self.conv1(x)
x=self.conv2(x)
x=self.conv3(x)
x=self.conv4(x)
x=self.conv5(x)
x=self.dropout(x)
x=self.fc1(x)
x=self.dropout(x)
x=self.fc2(x)
x=self.fc3(x)
return x
解决方案
推荐阅读
- html - 奇怪的图像定位(HTML、CSS、Bootstrap)
- vba - 如果单元格包含某些东西,那么
- angular - 如何根据从 docker-compose.yml 传递的环境变量修改 Dockerfile RUN 命令的效果
- r - 按名称排序并完成列表及其子列表
- php - php update mysql 一行没有更新
- css - 需要区分 bootbox.alert() 和 bootbox.confirm() 两种样式的modal在同一个页面
- c# - 如何截断表并更新与表链接的datagridview
- android - 模拟器不会显示我的应用
- php - 使用http客户端android studio在base64中上传图片
- postgresql - PostgreSQL - 当行以分隔符结尾时如何使用复制命令(导入文本文件)