Converting keras model to pytorch

Hi,
My Keras model looks something like this:
def init(self, in_channels=1):

    super(CNN, self).__init__()
    self.base_model = ResNet50(weights='imagenet', include_top=False)
    self.NUM_CLASSES = 22

    self.DENSE_LAYER_ACTIVATION = 'softmax'

    for layer in self.base_model.layers:
        layer.trainable = True
    #layer_name = 'conv1_relu'
    self.layer_name = 'conv3_block4_2_relu'
    #layer_name = 'conv2_block2_1_relu'
    self.intermediate_layer_model = Model(inputs=self.base_model.input,
                                    outputs=self.base_model.get_layer(self.layer_name).output)

    #w = self.intermediate_layer_model.output
    self.GAP = GlobalAveragePooling2D()
    self.Dropout = Dropout(rate=0.2)

    self.Dense1 = Dense(256, activation = 'relu')
    self.Dense2 = Dense(128, activation = 'relu')
    self.predictions = Dense(self.NUM_CLASSES,
            activation = self.DENSE_LAYER_ACTIVATION)

def forward(self, x):
    x=self.base_model.get_layer(self.layer_name)(x)
    print(x.shape)
    x=self.GAP(x)
    x=self.Dropout(x)
    x=self.Dense1(x)
    x=self.Dropout(x)
    x=self.Dense2(x)
    x=self.Dropout(x)
    x=self.predictions(x)

    return x

I want to convert this to pytorch. Any help would be greatly appreciated.
Thanks.

Where are you currently stuck in the conversion?
Based on the provided code I would assume that changing the layer names (e.g. Dense to nn.Linear) could solve the majority of the issues.

Thanks for the response.
Specifically:
a) How do I specify conv3_block4_2_relu?
b) How do i convert this line:
self.intermediate_layer_model = Model(inputs=self.base_model.input,
outputs=self.base_model.get_layer(self.layer_name).output)

I don’t know how Model is defined but assuming that self.layer_name gets an intermediate activation from ResNet50, you could either use forward hooks as described here or override the forward of the resnet implementation so that the desired activation will be returned.