Install & Compatibility
Where this runs
tested against v0.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
2148MB installed
● package 2148MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
unfoldNd
✓ from unfoldNd import unfoldNd
✗ from unfoldnd import unfoldNd
Package name is 'unfoldNd' with capital N, but pip install uses all lowercase.
foldNd
✓ from unfoldNd import foldNd
Demonstrates 3D unfolding and folding with a 3x3x3 kernel.
import torch
from unfoldNd import unfoldNd, foldNd
x = torch.randn(1, 3, 10, 10, 10) # N=3 kernel size 3x3x3
patches = unfoldNd(x, kernel_size=3, dilation=1, padding=0, stride=1)
print(patches.shape) # torch.Size([1, 27, 512])
# Fold back (example assumes same parameters)
x_reconstructed = foldNd(patches, output_size=(10,10,10), kernel_size=3, dilation=1, padding=0, stride=1)
print(x_reconstructed.shape) # torch.Size([1, 3, 10, 10, 10])
Errors
Common errors & fixes
ImportError: cannot import name 'unfoldNd' from 'unfoldnd'
Mixing up package name (unfoldnd) with module name (unfoldNd).
fixRun: from unfoldNd import unfoldNd
TypeError: foldNd() missing 1 required positional argument: 'output_size'
foldNd requires output_size parameter; it is not optional.
fixAdd 'output_size=(D, H, W)' (or appropriate dimensions) to the foldNd call.
RuntimeError: Expected 4D or 5D input tensor, but got 3D
unfoldNd expects at least a 4D tensor (batch, channels, spatial...).
fixEnsure input tensor has batch and channel dimensions, e.g., reshape to (1, 1, *spatial_dims) if needed.
Upgrade
Version history
0.2.3latest on PyPI · released Dec 30, 2024
Audit
Dependencies
torchrequiredCore dependency; library operates on PyTorch tensors.