How to access parameters in a certain layer of pretrained network?

Hi @pinata1337,

An easy way to find out it is to print your model:

>>> print(frcnn)
FasterRCNN(
  (transform): GeneralizedRCNNTransform()
  (backbone): Sequential(
    (0): ConvBNReLU(
      (0): Conv2d(3, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
      (1): BatchNorm2d(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
      (2): ReLU6(inplace=True)
    )
[...]

You can always access the submodules of a module by it’s named attribute (or index when the Module is a Sequential). So, in the case of FasterR-CNN, let’s say you want to access the first Conv2D in the first ConvBNReLU in backbone:

>>> frcnn.backbone[0][0]
Conv2d(3, 32, kernel_size=(3, 3), stride=(2, 2), padding=(1, 1), bias=False)
1 Like