deJQK
September 5, 2018, 2:43pm
3
Custom convolution layer can be implemented either by inheritance from the class nn.Conv2d, or through the funciton unfold. Unfortunately, unfold do not support dilation.
You may want to check these two topics:
Hi,
I want to implement a customized Conv2d in which some multiplications during the convolution operation are dropped by some probability. This would happen during testing, and preferably different multiplications would drop for different kernels in a layer. Is there an easy way to do this? Do I need to implement the Conv2d function using pytorch functions from scratch?
Thanks!
PyTorch provide the powerful function unfold, through both torch.nn.functional.unfold and the builtin function for tensor torch.Tensor.unfold . It seems the latter is easier to use, and it is more general as it is not restricted to 4D tensor. However, the former implementation support dilation, while the latter does not.
Does anyone has method to augment the builtin function implementation to make it support dilation?
Custom pooling can be implemented like this:
3 Likes