Fix DPT decoder bugs#26
Open
bingyic wants to merge 2 commits intoadd-decoders-modulefrom
Open
Conversation
- Add F.relu() after DPTHead project conv to match Scenic's output_activation=True default - Fix DepthDecoder to route through parent's nn.Linear head instead of bypassing it - Register bin_centers as a buffer with configurable num_depth_bins - Add weight key remapping for all decoder types
Three fixes verified by numerical parity tests (max abs diff < 1e-4): 1. GELU approximation: JAX defaults to tanh approximation, PyTorch uses exact. Use F.gelu(x, approximate='tanh') for numerical parity. 2. Remove spurious ReLU: Scenic DPT defaults to output_activation=False, so no ReLU should be applied after the project conv. 3. ConvTranspose kernel flip: Flax ConvTranspose uses transpose_kernel=False (no kernel flip), while PyTorch ConvTranspose2d always flips. Pre-flip weights 180 degrees during loading to compensate. These fixes bring the max absolute difference between Scenic and PyTorch decoder outputs below 1e-4 across all three heads (depth, normals, segmentation). No checkpoint re-export needed — all fixes are in the inference code/weight loading path.
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 PR applies fixes to the DPT decoders introduced in PR #24.
Changes: