Skip to content

Fix step activation docstring to match >= threshold behavior#3902

Open
ayaangazali wants to merge 1 commit into
ml-explore:mainfrom
ayaangazali:fix-step-docstring
Open

Fix step activation docstring to match >= threshold behavior#3902
ayaangazali wants to merge 1 commit into
ml-explore:mainfrom
ayaangazali:fix-step-docstring

Conversation

@ayaangazali

Copy link
Copy Markdown
Contributor

Proposed changes

The step function and Step module docstrings say the output is "1 if the input is greater than a specified threshold", but the implementation is mx.where(x >= threshold, 1, 0) and the math block right below the prose already uses x >= threshold. So the prose was the only part that disagreed. Quick check on main:

import mlx.core as mx
import mlx.nn as nn

nn.Step(0.0)(mx.array([-1.0, 0.0, 1.0])).tolist()  # [0, 1, 1]  -> 0 maps to 1, i.e. >=

Updated the prose to "greater than or equal to" in both places, and documented the threshold default (0.0) while I was there.

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING document
  • I have run pre-commit run --all-files to format my code / installed pre-commit prior to committing changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have updated the necessary documentation (if needed)

(docstring-only, test_nn.py still passes 69/69)


quick note: i'm a freshman still learning, and i lean on Claude Code to surface these doc/code mismatches, but i ran the snippet above myself to confirm the boundary value maps to 1 before writing this. happy to adjust if you'd word it differently.

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.

1 participant