import torch.nn as nn

class LeNet_1D_V(nn.Module): def init(self): super(LeNet_1D_V, self).init() self.conv1 = nn.Sequential( nn.Conv1d(1, 5, kernel_size=3, stride=1, padding=1), nn.Mish() ) self.conv2 = nn.Sequential( nn.Conv1d(5, 10, kernel_size=3, stride=1, padding=1), nn.Mish() ) self.conv3 = nn.Sequential( nn.Conv1d(10, 15, kernel_size=3, stride=1, padding=1), nn.Mish() ) self.conv4 = nn.Sequential( nn.Conv1d(15, 20, kernel_size=3, stride=1, padding=1), nn.Mish() ) self.conv5 = nn.Sequential( nn.Conv1d(20, 25, kernel_size=3, stride=1, padding=1), nn.Mish() ) self.conv6 = nn.Sequential( nn.Conv1d(25, 30, kernel_size=3, stride=1, padding=1), nn.Mish() ) self.conv7 = nn.Sequential( nn.Conv1d(30, 35, kernel_size=3, stride=1, padding=1), nn.Mish() ) self.conv8 = nn.Sequential( nn.Conv1d(35, 40, kernel_size=3, stride=1, padding=1), nn.Mish() ) self.avgpool = nn.AvgPool1d(kernel_size=2, stride=1) self.global_avgpool = nn.AdaptiveAvgPool1d(1) self.fc = nn.Linear(40, 6) self.softmax = nn.Softmax(dim=1)

def forward(self, x):
    x = self.conv1(x)
    x = self.avgpool(x)
    x = self.conv2(x)
    x = self.avgpool(x)
    x = self.conv3(x)
    x = self.avgpool(x)
    x = self.conv4(x)
    x = self.avgpool(x)
    x = self.conv5(x)
    x = self.avgpool(x)
    x = self.conv6(x)
    x = self.avgpool(x)
    x = self.conv7(x)
    x = self.avgpool(x)
    x = self.conv8(x)
    x = self.global_avgpool(x)
    x = x.view(x.size(0), -1)
    feature = x
    x = self.fc(x)
    output = self.softmax(x)
    return feature, output

model = LeNet_1D_V() print(model)

LeNet-1D-V: A 1D Convolutional Neural Network for Classification

原文地址: https://www.cveoy.top/t/topic/pi8b 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录