From 8a3d9451e07317548c190ba0b47921eed5b7687f Mon Sep 17 00:00:00 2001 From: David Rotermund <54365609+davrot@users.noreply.github.com> Date: Sat, 3 Feb 2024 15:49:29 +0100 Subject: [PATCH] Add files via upload --- reproduction_effort/functions/binning.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 reproduction_effort/functions/binning.py diff --git a/reproduction_effort/functions/binning.py b/reproduction_effort/functions/binning.py new file mode 100644 index 0000000..5e1cebb --- /dev/null +++ b/reproduction_effort/functions/binning.py @@ -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) + )