How to create a custom convolutional autograd function

I am trying to implement the Direct Feedback Alignment training method and I want to create a custom Convolutional 2d layer which on the backward pass the input gradient is multiplied by a random initialized weight. Analogous to this Linear implementation. I tried to look on the F.Conv2d implementation but it’s C code.
Is there some Python Autograd Function implementation of the convolution over 2d inputs?

You could write a custom conv implementation in Python using nn.Unfold.
The docs give you an example of a convolution, but note that you might see a low performance.

1 Like