可以帮我看看吗
class cnn1d(nn.Module):
def __init__(self):
super(cnn1d, self).__init__()
self.conv_unit = nn.Sequential(
nn.BatchNorm1d(1), #定义维度为1的归一化函数
nn.Conv1d(in_channels=1,out_channels=32,kernel_size=11,stride=1,padding=5), #第一个卷积层
nn.BatchNorm1d(32),#定义维度为32的归一化函数
nn.LeakyReLU(), #激活函数
nn.MaxPool1d(4), #第一个最大池化层
nn.Conv1d(in_channels=32,out_channels=64,kernel_size=11,stride=1,padding=5),#第二个卷积层
nn.BatchNorm1d(64),#定义维度为64的归一化函数
nn.LeakyReLU(),#激活函数
nn.MaxPool1d(4), #第二个最大池化层
nn.Conv1d(in_channels=64,out_channels=128,kernel_size=3,stride=1,padding=1),#第三个卷积层
nn.LeakyReLU(),#激活函数
nn.MaxPool1d(4), #第三个最大池化层
nn.Dropout(0.1), #防止过拟合
)
self.dense_unit = nn.Sequential(
nn.Linear(3072,1024), #设置全连接层1
nn.LeakyReLU(),
nn.Linear(1024,128), #设置全连接层2
nn.LeakyReLU(),
nn.Linear(128,4), #设置全连接层3
)
def forward(self, x): #前向传播
x = x.view(x.size()[0],1,x.size()[1])
# 转换成conv1d的input size(batch size, channel, series length)
x = self.conv_unit(x)
x = x.view(x.size()[0],-1)
x = self.dense_unit(x)
return x