Padding_mode argument for convolutional layers, only zeros and circular? How to do reflection padding?

I have been looking into how to do reflection/mirror padding of some images and activation maps rather than the default zero padding. I have 3D images so I cannot use torch.nn.ReflectionPad3d (does not exist). It seems like I could use torch.nn.functional for this, but I would prefer to keep something that fits into my torch.nn.Sequential blocks in __ init __ more cohesively, and I was unsure of how to do it with functional.

Then I saw something called “padding_mode” in torch.nn.Conv3d, which I think could be what I am looking for. However, the documentation only says “zeros” and “circular” as the padding_mode options, and does not have listed “replicate” or “reflect”. How can I use the padding_mode attribute to do reflection padding? Here is the documentation where I saw “zeros” and “circular” listed:


1 Like