Skip to content

Instantly share code, notes, and snippets.

@rwightman
rwightman / median_pool.py
Last active March 15, 2024 12:55
PyTorch MedianPool (MedianFilter)
import math
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.nn.modules.utils import _pair, _quadruple
class MedianPool2d(nn.Module):
""" Median pool (usable as median filter when stride=1) module.