File size: 1,404 Bytes
320e2b9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import torch
import torch.nn as nn

from custom_layers.SSRP_MS import SSRP_MS
from custom_layers.WavKAN import WavKANLinear
from custom_layers.PCAw_Pool import PCAw_Pool


class CNN_PCAw_SSRPMS_KAN(nn.Module):
    def __init__(self, num_classes):
        super(CNN_PCAw_SSRPMS_KAN, self).__init__()

        self.conv1 = nn.Sequential(
            nn.ZeroPad2d((0, 0, 0, 1)),
            nn.Conv2d(1, 64, kernel_size=3),
            nn.BatchNorm2d(64),
            nn.ReLU(),
            PCAw_Pool(kernel_size=(3, 3), stride=(3, 3)),
        )

        self.conv2 = nn.Sequential(
            nn.ZeroPad2d((0, 0, 0, 1)),
            nn.Conv2d(64, 128, kernel_size=3),
            nn.BatchNorm2d(128),
            nn.ReLU(),
            nn.AvgPool2d(kernel_size=(2, 2), stride=(2, 2)),
        )

        self.conv3 = nn.Sequential(
            nn.Conv2d(128, 256, kernel_size=3),
            nn.BatchNorm2d(256),
            nn.ReLU()
        )

        self.ssrp_ms = SSRP_MS(base_window=3, num_levels=5)
        self.flatten = nn.Flatten()

        self.fc = nn.Linear(1024, 128)
        self.kan = WavKANLinear(128, num_classes)

    def forward(self, x):
        x = self.conv1(x)
        x = self.conv2(x)
        x = self.conv3(x)
        x = self.ssrp_ms(x)
        x = self.flatten(x)
        x = self.fc(x)
        x = self.kan(x)
        return x