Given a container
model = nn.Sequential(
nn.Conv2d(1,20,5),
nn.ReLU(),
nn.Conv2d(20,64,5),
nn.ReLU()
nn.Conv2d(64,128,5),
nn.ReLU()
nn.Conv2d(128,128,5),
nn.ReLU()
)
I would like to extract some of the features with indexing.
feats = model[:2]
TypeError: ‘<’ not supported between instances of ‘slice’ and ‘int’
The current best solution I’m guessing is to do this:
feats = nn.Sequential( *(model[i] for i in range(2)) )
Will the former solution be possible later or is there an alternative solution?