class TPCNN(nn.Module): def __init__(self, num_class=10, head_payload=False): super(TPCNN, self).__init__() # 上 self.uconv1 = nn.Sequential( # nn.Conv2d(1, 16, kernel_size=3, stride=1, padding=1, dilation=1, bias=True), nn.BatchNorm2d(16, eps=1e-05, momentum=0.9, affine=True), nn.ReLU(), ) self.uconv2 = nn.Sequential( # nn.Conv2d(16, 32, kernel_size=3, stride=2, padding=1, dilation=1, bias=True), nn.BatchNorm2d(32, eps=1e-05, momentum=0.9, affine=True), nn.ReLU(), ) # 中 self.mconv1 = nn.Sequential( # nn.Conv2d(1, 32, kernel_size=3, stride=2, padding=1, dilation=1, bias=True), nn.BatchNorm2d(32, eps=1e-05, momentum=0.9, affine=True), nn.ReLU(), ) # 下 self.dconv1 = nn.Sequential( # nn.Conv2d(1, 32, kernel_size=3, stride=1, padding=1, dilation=1, bias=True), nn.BatchNorm2d(32, eps=1e-05, momentum=0.9, affine=True), nn.ReLU(), nn.MaxPool2d(kernel_size=2) ) self.uconv3 = nn.Sequential( # nn.Conv2d(96, 128, kernel_size=3, stride=1, padding=1, dilation=1, bias=True), nn.BatchNorm2d(128, eps=1e-05, momentum=0.9, affine=True), nn.ReLU(), ) self.mconv2 = nn.Sequential( # nn.Conv2d(96, 128, kernel_size=3, stride=2, padding=1, dilation=1, bias=True), nn.BatchNorm2d(128, eps=1e-05, momentum=0.9, affine=True), nn.ReLU(), ) self.dconv2 = nn.Sequential( # nn.Conv2d(96, 128, kernel_size=3, stride=1, padding=1, dilation=1, bias=True), nn.BatchNorm2d(128, eps=1e-05, momentum=0.9, affine=True), nn.ReLU(), ) self.uconv4 = nn.Sequential( # nn.Conv2d(256, 512, kernel_size=3, stride=2, padding=1, dilation=1, bias=True), nn.BatchNorm2d(512, eps=1e-05, momentum=0.9, affine=True), nn.ReLU(), ) self.globalconv1 = nn.Sequential( nn.Conv2d(896, 1024, kernel_size=3, stride=1, padding=1), nn.BatchNorm2d(1024, eps=1e-05, momentum=0.9, affine=True), nn.ReLU() ) self.dmaxpool = nn.MaxPool2d(kernel_size=2,padding=1) # self.lstm1 = nn.LSTM(256,512, 2) # self.lstm2 = nn.LSTM(self.i_size*2,self.i_size*2, 2) self.avpool = nn.AdaptiveAvgPool2d(2) # self.globallstm = nn.LSTM(512, 256, 1) self.fc1 = nn.Linear(1024*2*2, 512) self.fc2 = nn.Linear(512, num_class)
时间: 2023-06-08 20:04:07 浏览: 190
USB_Video_Payload_DV_1.1.rar_The Class_usb video class
这段代码定义了一个名为TPCNN的类,继承自nn.Module。它具有一个num_class参数,默认值为10,以及一个head_payload参数,其默认值为False。在__init__函数中,它首先调用父类的构造函数,然后定义了该类的其余属性和方法。
阅读全文