Check filter type in convolutional layer CNN

i build unet encoder with pretrained resnet34 with weight from imagenet

resnet = models.resnet34(weights=models.resnet.ResNet34_Weights.IMAGENET1K_V1)

class Encoder(nn.Module):
    def __init__(self):
        self.layer1 = nn.Sequential(
            nn.LeakyReLU(negative_slope=0.1, inplace=True),
        self.layer2 = resnet.layer2
        self.layer3 = resnet.layer3
        self.layer4 = resnet.layer4
    def forward(self, x):
        x1 = self.layer1(x)
        x2 = self.layer2(x1)
        x3 = self.layer3(x2)
        x4 = self.layer4(x3)
        return x1, x2, x3, x4

i want to check the filters type used in each convolutional layer (e.g like sobel, prewitt, gaussian, etc). How can i check that?

The filters of conv layers are trained and while they might learn common image processing filters there won’t be a guarantee they will.
You can access the filters via the .weight attribute in each conv layer and could then try to visualize it.

Thank you! Is there any difference if i acces the weight before or after training? And how do i visualize it?

Yes, there will be a difference since the weigth attribute, which represents the filters, is trained.
You could visualize each input channel of each filter using e.g.:

conv = nn.Conv2d(in_channels=8, out_channels=16, kernel_size=3)
out = make_grid(conv.weight.view(-1, 1, conv.weight.size(2), conv.weight.size(3)), nrow=conv.out_channels, normalize=True)
plt.imshow(out.permute(1, 2, 0).numpy())


ah get it, thank you!