一维卷积网络与BatchNorm1d、MaxPool1d联合使用
class CNN1d(nn.Module):
def __init__(self):
super(CNN1d,self).__init__()
self.layer1 = nn.Sequential(
nn.Conv1d(1,100,2),
nn.BatchNorm1d(100),
nn.ReLU(),
nn.MaxPool1d(3, 2))
self.layer2 = nn.Sequential(
nn.Conv1d(100,50,2),
nn.BatchNorm1d(50),
nn.ReLU(),
nn.MaxPool1d(3, 2))
self.fc = nn.Linear(300,6)
def forward(self,x):
#input.shape:(16,1,425)
out = self.layer1(x)
out = out.view(out.size(0),-1)
out = self.fc(out)
return out
该文章介绍了一个使用PyTorch实现的一维卷积神经网络模型,模型包含两层Conv1d,每层后面跟着BatchNorm1d用于规范化和ReLU激活函数,接着是MaxPool1d进行最大池化。最后通过全连接层fc进行分类。输入尺寸为(16,1,425),输出维度为6。
4118

被折叠的 条评论
为什么被折叠?



