Making a custom CNN architecture using pytorch

I am trying to make a custom CNN architecture using Pytorch. I want to have about the same control as what I would get if I make the architecture using numpy only.

I am new to Pytorch and would like to see some code samples of CNNs implemented without the nn.module class, if possible.

Why don’t you want using nn.Module ? You have full control on what happens. For CNN you have to build on a Module because you can’t have in the same nn.Sequential Conv and Linear (except is you use a custom Flatten layer). The PyTorch example speaks by itself. Just change the layers, the activations (which can be layers too).

In the CNN that I am trying to make there are certain intermediate layers that I don’t want to be optimised and I can’t find anything in the tutorial on this.
Also I am experimenting with hidden layers of different characteristics than the typical linear one.

Look for “autograd” and how to freeze layers.
If you don’t want to use Linear layers, you pick ones already existing or look how to build custom ones

1 Like