Skip to content

Reject non-finite inputs in softmax function - #15770

Open
mehulikhanra904-prog wants to merge 3 commits into
TheAlgorithms:masterfrom
mehulikhanra904-prog:improve-activation-functions
Open

mehulikhanra904-prog wants to merge 3 commits into
TheAlgorithms:masterfrom
mehulikhanra904-prog:improve-activation-functions

Conversation

@mehulikhanra904-prog

Copy link
Copy Markdown

Describe your change

  • Fix a bug or typo in an existing algorithm?
  • Add or change doctests?

Changes

  • Added validation to reject NaN and infinite input values.
  • Improved input validation with clear ValueError messages.
  • Preserved numerical stability by subtracting the maximum input value.
  • Retained empty-input and invalid-axis validation.
  • Added doctests for non-finite input handling.

Checklist

  • I have read the contributing guidelines.
  • This pull request is my own work.
  • I understand that pull requests must pass automated tests.
  • This PR changes only one algorithm file.
  • Function names follow Python naming conventions.
  • Type hints are included.
  • Doctests are included.

No existing issue is being resolved.

@algorithms-keeper algorithms-keeper Bot added awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files labels Nov 17, 2026

This branch has not been deployed

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

Labels

awaiting reviews This PR is ready to be reviewed enhancement This PR modified some existing files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant