Hi;
I am trying the truncate the resnet 18 model. I would like to truncate the model after the 2nd convolution
import torch
import torchvision
model= torchvision.model.resnet18(pretrained=True)
*trun_ model = nn.Sequential(list(model.children()[:1])
I get the first conv
continuing in this fashion
*trun_ model = nn.Sequential(list(model.children()[:5])
Sequential (
** (0): Conv2d(3, 64, kernel_size=(7, 7), stride=(2, 2), padding=(3, 3), bias=False)**
** (1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True)**
** (2): ReLU (inplace)**
** (3): MaxPool2d (size=(3, 3), stride=(2, 2), padding=(1, 1), dilation=(1, 1))**
** (4): Sequential (**
** (0): BasicBlock (**
** (conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)**
** (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True)**
** (relu): ReLU (inplace)**
** (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)**
** (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True)**
** )**
** (1): BasicBlock (**
** (conv1): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)**
** (bn1): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True)**
** (relu): ReLU (inplace)**
** (conv2): Conv2d(64, 64, kernel_size=(3, 3), stride=(1, 1), padding=(1, 1), bias=False)**
** (bn2): BatchNorm2d(64, eps=1e-05, momentum=0.1, affine=True)**
** )**
** )**
)
However I would like model to truncate after only the First Conv in Basic Block 0
Any ideas ?