Refactor codebase: package restructure, pyproject.toml migration, and full internal refactor#1
Open
alexwolson wants to merge 14 commits intooptimal-uoft:mainfrom
Open
Refactor codebase: package restructure, pyproject.toml migration, and full internal refactor#1alexwolson wants to merge 14 commits intooptimal-uoft:mainfrom
alexwolson wants to merge 14 commits intooptimal-uoft:mainfrom
Conversation
Co-authored-by: alexwolson <8996640+alexwolson@users.noreply.github.com>
Co-authored-by: alexwolson <8996640+alexwolson@users.noreply.github.com>
Co-authored-by: alexwolson <8996640+alexwolson@users.noreply.github.com>
…ize-files Refactor repository structure and migrate to pyproject.toml
Co-authored-by: alexwolson <8996640+alexwolson@users.noreply.github.com>
Co-authored-by: alexwolson <8996640+alexwolson@users.noreply.github.com>
Co-authored-by: alexwolson <8996640+alexwolson@users.noreply.github.com>
Co-authored-by: alexwolson <8996640+alexwolson@users.noreply.github.com>
Co-authored-by: alexwolson <8996640+alexwolson@users.noreply.github.com>
Co-authored-by: alexwolson <8996640+alexwolson@users.noreply.github.com>
Refactor codebase: vectorize operations, add validation, fix deprecations
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request consolidates two major refactoring efforts into a single, cohesive update. It modernizes the repository structure and dependency management, while also performing a deep internal refactor to improve correctness, performance, validation, and long-term maintainability.
1. Repository & Packaging Modernization
Package structure
neurcam/model.py,loss.py, and__init__.pyNeurCAM.py,Loss.py)py.typedmarker to support static type checkingDependency management
environment.ymlwithpyproject.tomlhatchlingbuild backenddevfor development toolingwrdsfor optional integrationsImport path update
2. Compatibility & Deprecation Fixes
verboseparameter fromReduceLROnPlateau(PyTorch 2.x)verbose=Falseverbose"torch.optim.lr_scheduler.LRScheduler")3. Full Internal Code Refactor
Correctness fixes
scheduler.step()to run once per epoch (after the batch loop) instead of once per batchtorch.cdist()usage inFuzzyCMeansLossby removing unnecessaryunsqueeze()/squeeze()Validation improvements
NeurCAM(e.g.,k,m,epochs,batch_size, etc.)NeurCAMModel(e.g.,input_dim,repr_dim, etc.)FuzzyCMeansLoss(e.g.,m)kl_weight(must be non-negative)single_feature_channelsandpairwise_feature_channels(must be non-negative)"cuda:0","cuda:1","mps","cpu", etc.)Performance & code quality
_o1_valid_cutsand_o2_valid_cutsto remove loop-based logic and reduce duplication_forwardto avoid unnecessary.to()calls_prepare_data_separated_forward_o1_build_projection_networkusingextend()4. Status