AFAIK, it’s best not to use the functional API(F.pad) for adding layers, especially those that mutate the shape of their input. The layers won’t show up in the model description and will create a problem in inferring how the shape of the feature maps evolve as the network progresses.
torch.nn layers make life easier.(Refer @duang’s example above).