Design my own resnet using torch.nn.Sequential, possible?

Hello

I have been playing with a basic fully connected neuralNet using the Sequential function.

dcn.NN = torch.nn.Sequential(
torch.nn.Linear(dcn.d, dcn.hidden_d, bias=True),
torch.nn.ReLU(),
torch.nn.Linear(dcn.hidden_d, dcn.hidden_d, bias=True),
torch.nn.ReLU(),
torch.nn.Linear(dcn.hidden_d, dcn.hidden_d, bias=True),
torch.nn.ReLU(),
torch.nn.Linear(dcn.hidden_d, dcn.hidden_d, bias=True),
torch.nn.ReLU(),
torch.nn.Linear(dcn.hidden_d, dcn.output_d, bias=True),
torch.nn.Softmax(dim=1)
)

I know that pytorch has a pre-packaged resnet in the library. But to my understanding, it is a CNN. If I want a basic fully connected neuralNet with resnet structure, I assume I would need to build it myself? If so how do I do it using the Sequential function? Or do I have to do it without using the Sequential method?

Thank you in advanced.

Chieh

1 Like

you have to do it without the Sequential container, because you have to do the += operation (i.e. residual connection)

I also want to know. Duplicate: How to have Residual Network using only Sequential Blocks?