Skip to content

R23-T054: Add ELU edge-value and SELU/Leaky ReLU agreement doctests - #64

Open
code-paul-creator wants to merge 1 commit into
S-AI-Projects:masterfrom
code-paul-creator:R23-T054
Open

code-paul-creator wants to merge 1 commit into
S-AI-Projects:masterfrom
code-paul-creator:R23-T054

Conversation

@code-paul-creator

Copy link
Copy Markdown

Description

Compares exponential_linear_unit.py with scaled_exponential_linear_unit.py and leaky_rectified_linear_unit.py (API, numeric agreement, edge values, speed) and adds doctests to ELU that pin down the results: edge values, agreement with SELU at scale 1 and at SELU's documented constants, and agreement with Leaky ReLU on positive inputs.

Related Issue

Fixes: #54

Type of Change

  • Bug Fix
  • New Feature
  • UI/UX Improvement
  • Performance Improvement
  • Tests
  • Documentation
  • Refactoring / Maintenance
  • CI/CD

Changes Made

  • Added doctests to exponential_linear_unit for 0, large negative (-1000 saturates at -alpha), alpha=0, ELU == SELU(lambda_=1), SELU defaults == 1.0507 * ELU(x, 1.6732), and ELU == Leaky ReLU for positive inputs (existing 2 doctests unchanged; 13 total).
  • Added work/R23-T054/compare_test.py (19 checks over 14 shared inputs and 5 alphas), bench_compare.py, and COMPARE.md (API differences, results, edge values, speed, beginner recommendation).

Screenshots / Recordings

Not applicable (no UI changes).

Testing

  • python -m pytest --doctest-modules neural_network/activation_functions/exponential_linear_unit.py -> passed (13 doctests)
  • python -m pytest work/R23-T054/compare_test.py -> 19 passed
  • ruff check neural_network/activation_functions/exponential_linear_unit.py -> all checks passed

Checklist

  • I have tested my changes locally.
  • I have added or updated tests, if needed.
  • I have updated documentation, if needed.
  • I have followed the project's coding guidelines.
  • I have run the relevant tests and checks.
  • I have addressed previous review feedback, if applicable.

Additional Notes

Findings: ELU == SELU exactly when lambda_=1; ELU == Leaky ReLU on all positive inputs; all three give 0 at 0; they differ on negatives (ELU saturates at -alpha, Leaky ReLU is unbounded). A large positive input (e.g. 1000) returns the right value but emits RuntimeWarning: overflow encountered in exp in ELU/SELU because np.where evaluates both branches; not changed here. Details in work/R23-T054/COMPARE.md.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Paulami Bhosle — R23-T054: Compare neural_network/activation_functions/exponential_linear_unit.py with related code in the repo

1 participant