By the way, I have searched the forums and found some related posts, but not the answer to my question. For example:

  
    
    
    Using output of one network in another with only one loss function autograd
  
  
    I am using two neural networks say NN1 and NN2. Output of NN1 is used in forward function of NN2 and output of forward function of NN2 is the loss required. So in the training loop if I write 
loss = NN2(data) 
loss.backward()

Will this update the weights of both NN1 and NN2?
  



  
    
    
    How can I connect a new neural network after a trained neural network and optimize them together 
  
  
    Ah OK, thanks for the information. 
You can get the kernel size using conv.kernel_size and store it in your config file.