Why F.unfold() and F.fold() use?

Hello. I have a question about F.unfold() and F.fold()

I understand how to operate F.unfold() and F.fold(), but i don’t understand why they need.

I wonder what kind of situation it is usually used in. (especially, in vision context.)

Thanks.

You could unfold an image tensor, apply a convolution via a matrix multiplication, and fold it back to the desired output in order to e.g. write a custom conv (where you could add additional operations), for custom pooling layers etc.
Also, creating “windows” from e.g. time signals can use the same approach.

1 Like