Add files via upload

This commit is contained in:
David Rotermund 2024-02-03 15:49:29 +01:00 committed by GitHub
parent ec4b7eae41
commit 8a3d9451e0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -0,0 +1,20 @@
import torch
def binning(
data: torch.Tensor,
kernel_size: int = 4,
stride: int = 4,
divisor_override: int | None = 1,
) -> torch.Tensor:
return (
torch.nn.functional.avg_pool2d(
input=data.movedim(0, -1).movedim(0, -1),
kernel_size=kernel_size,
stride=stride,
divisor_override=divisor_override,
)
.movedim(-1, 0)
.movedim(-1, 0)
)