Open
Conversation
Add Problem #41 covering tanh forward, manual backward, and logit soft-capping (used in Gemma 2, Griffin). Includes numerically stable implementation using 2/(1+exp(-2x))-1 to handle large inputs. - templates/41_tanh.ipynb: template with 3 function stubs - solutions/41_tanh_solution.ipynb: working solution (stable formula) - torch_judge/tasks/tanh.py: 6 judge tests (accuracy, bounds, shape, gradient, manual backward, soft-capping) - README.md: add row to Fundamentals table, bump badge 40 β 41 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
Adds a new Easy-difficulty problem where users implement tanh activation using three parts:
exp, numerically stable via2/(1+exp(-2x))-11 - tanhΒ²(x), note it depends on the output not the inputcap Β· tanh(logits/cap), a technique used in Gemma 2 and Griffin to bound logitsMotivation
Files Changed
torch_judge/tasks/tanh.pytemplates/41_tanh.ipynbsolutions/41_tanh_solution.ipynbREADME.mdTest Cases
Conventions Followed
_registry.pyβ no manual registration needed{fn}placeholder in all test codetorch.allclose()for numerical comparison with appropriate tolerancesHow to Test
Open
solutions/41_tanh_solution.ipynbin JupyterLab and run all cells β the finalcheck('tanh')should show 6/6 tests passed.