Closed sremedios closed 3 years ago
Hi, thanks for your feature request.
I have no experience with torch.nn.Fold
and hence cannot make any statements about the existence of a similar one-hot convolution trick to parametrize fold
. So at the moment there is no plan to support it.
I would be curious to think about it, though.
Actually my use case is very simple. If I have called unfoldNd and extract non-overlapping Nd patches, I would like to "invert" this operation. In particular, if I extract, for example, 32 x 32 x 32 non-overlapping patches from a 256 x 256 x 256 image, I want to be able to perform some operation on each patch independently, then stitch them back together to the 256 x 256 x 256 image.
Hi again,
I managed to reproduce the behavior of fold
in the provided docstring example here in a short evening session. I don't see any reason why this prototype should not generalize to 5d inputs; so FoldNd
is possible.
However, it will take some time (I'll only be able to do this on weekends) to clean up the existing implementation, and, more importantly, add proper tests (+ other unforeseen events). Here's the outline for testing FoldNd
:
torch.nn.Fold
on 3d and 4d tensors with large coverage of hyperparametersfoldNd(unfoldNd(input)) == input
on 3d, 4d and 5d inputsFoldNd
on a 5d input with overlapping patchesI am reaching out to you for help with the last task; basically because I am not familiar with how the method is supposed to work in all edge cases. This requires hard-coding a 5d input tensor, and the expected result returned from fold
, i.e. filling out the following entries:
inputs = ... # hard-coded 5d tensor
fold_params = ... # non-overlapping patches
output = ... # expected result
It would be great if you let me know whether you are willing to provide such an example test case to decrease the functionality's shipping time.
Thanks for getting back to me. In the interim I actually found scikit functions which served my purpose: with skimage.util.view_as_blocks
and skimage.util.view_as_windows
I was able to meet my use case.
Great. Thanks for posting the issue. FoldNd
may be a cool application for using UnfoldNd
, and may even be supported by this library in the future.
Available in 0.1.0
Are there any plans to implement foldNd, the "inverse" of unfoldNd?