How mendozacortesgroup/poset-filters works
Project type and purpose
• Type: Open-source Python library for custom neural-network pooling (“poset filters”).
• Purpose: Provide implementations of convolutional filters based on partially ordered sets (posets) to replace/augment standard pooling layers in PyTorch models.
File structure
Top-level files/directories:
• poset_utils.py – main implementation (filter_n, PosetFilter, dict_posets)
• debugging/_poset_utils.py – variant with internal dictionary tweaks for backprop tests
• img/ – reference assets (table of poset indices)
• test/test.py – unit tests for forward/backward logic
• LICENSE, README.md, .gitignore
Key insights from README
• Core API: two entry points – filter_n (fixed poset N) and PosetFilter(coeffs=…)
• Integration: users import these functions into their nn.Module init/forward
• Dependencies: Python ≥3.7, PyTorch ≥2.2.0
• Testing: forward tests use poset_utils.py; backprop tests use debugging/_poset_utils.py
Main components
A. Client code (User’s PyTorch nn.Module)
B. poset-filters library
1. poset_utils.py
– filter_n factory
– PosetFilter class
– dict_posets (poset coefficient store)
2. debugging/_poset_utils.py (alternate dict_posets for backprop verification)
C. PyTorch framework
– torch.nn.Module
– torch.Tensor data flow
D. Test suite
– test/test.py (unit-test runner)
E. External resources
– img/table.png (documentation)
Relationships and data flow
• User’s nn.Module imports filter_n or PosetFilter → constructs a poset pooling layer.
• In forward pass: input Tensor → poset filter code (poset_utils or debugging) → output Tensor.
• Backpropagation: PyTorch autograd engine drives gradient flow through the filter implementation.
• Tests invoke forward/backward via Python unittest on both poset_utils.py and debugging module.
Architectural patterns & design principles
• Plugin pattern – poset filters slot into any nn.Module as a drop-in layer.
• Single responsibility – poset_utils handles API, coefficient lookup, convolution logic.
• Separation of concerns – debugging version is isolated under debugging/ for backprop tests.
• Extensibility – dict_posets can be extended with new poset definitions.