Multi-class merging with arbitrary class axis placement (resolves #20) - #30
Open
the-lay wants to merge 1 commit into
Open
Multi-class merging with arbitrary class axis placement (resolves #20)#30the-lay wants to merge 1 commit into
the-lay wants to merge 1 commit into
Conversation
Resolves #20, supersedes #21. - Merger(logits=N, logits_dim=d) places the class axis at any position of the added tiles and the merged output (negative indexing allowed); the default logits_dim=0 reproduces the previous prepend-only behavior exactly - Merger(ignore_channels=True) makes Merger expect tiles without the Tiler's channel dimension, for models that consume all channels and emit per-class or single-map predictions - merge(argmax=True) argmaxes the logits axis wherever it is - weights/visits buffers stay class-axis-free (same weight per class), with broadcasting handled at normalization time Compared to the 2022 prototype in #21, the public surface is smaller: the logits parameter keeps its name and semantics, argmax stays a bool (an int argmax would silently treat True as axis 1), and buffer names are unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PvVX1JaNVaXJ2PJEu4KJzE
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.
What & why
Rebuilds the 2022 multiclass Merger prototype (PR #21, unmergeable since the src-layout move) on the current codebase. Resolves #20 — the only externally-reported feature gap, open since 2022: model outputs like
(256, 256, 6)for input tiles(256, 256, 4)were rejected byMerger.addbecause the class axis could only be prepended.Stacked on #29 (revival baseline) — merge that first; GitHub will retarget this PR automatically.
API (deliberately smaller than the #21 prototype)
Merger(logits=N, logits_dim=d)— place the class axis at any position of the added tiles and merged output; negative indexing allowed. Defaultlogits_dim=0reproduces the previous prepend-only behavior exactly (verified by an equivalence test and the untouched pre-existing suite).Merger(ignore_channels=True)— expect tiles without the Tiler's channel dimension, for models that consume all channels and emit class logits (the [IDEA] Figuring out how to use this library with TensorFlow multi-class and binary classification #20 scenario) or a single map. Requireschannel_dimensionon the Tiler.merge(argmax=True)— argmaxes the logits axis wherever it lives.Differences from the #21 sketch, for the record:
logitskeeps its name and validation (nologits_nrename),argmaxstays a bool — #21'sargmax: Optional[int]would have silently treatedargmax=Trueas axis 1 — and no buffer renames (weights_sum/data_visits/save_visitsuntouched), so nothing breaks for existing users.Implementation notes
np.expand_dims.ignore_channels, the applied window drops the channel axis (which is always boxcar-weighted) and tile bboxes come fromget_tile_bbox(..., with_channel_dim=False).Verification
🤖 Generated with Claude Code
https://claude.ai/code/session_01PvVX1JaNVaXJ2PJEu4KJzE