I don’t know which line of code raises this error, but you are correct that F.unfold expects 4-dimensional tensors. For other shapes you could call tensor.unfold directly and would then have to specify the dimensions in each call.