我就废话不多说了,大家还是直接看代码吧~
import torch.nn as nn
import torch.nn.functional as F
import torch.nn as nn
class AlexNet_1(nn.Module):
def __init__(self, num_classes=n):
super(AlexNet, self).__init__()
self.features = nn.Sequential(
nn.Conv2d(
PyTorch: https://github.com/shanglianlm0525/PyTorch-Networks
import torch
import torch.nn as nn
import torchvision
class AlexNet(nn.Module):
def __init__(self,num_classes=1000):
super(AlexNet,self).__init__()
self.feature_extraction = nn
当使用pytorch写网络结构的时候,本人发现在卷积层与第一个全连接层的全连接层的input_features不知道该写多少?一开始本人的做法是对着pytorch官网的公式推,但是总是算错。
后来发现,写完卷积层后可以根据模拟神经网络的前向传播得出这个。
全连接层的input_features是多少。首先来看一下这个简单的网络。这个卷积的Sequential本人就不再啰嗦了,现在看nn.Linear(???, 4096)这个全连接层的第一个参数该为多少呢?
请看下文详解。
class Alex