Skip to content

docs: document tanh, leaky_relu, gelu, visualize and visualize_dot - #84

Merged
Terminay merged 1 commit into
Terminay:mainfrom
bh-official:docs/tensor-missing-methods
Oct 26, 2026
Merged

Terminay merged 1 commit into
Terminay:mainfrom
bh-official:docs/tensor-missing-methods

Conversation

@bh-official

Copy link
Copy Markdown
Contributor

Refs #4

Documents the missing methods in docs/api-reference/tensor.md:

  • tanh(), leaky_relu(negative_slope=0.01), gelu() (placed after sigmoid())
  • visualize(), visualize_dot() (placed after matmul())

gelu() is described as the tanh approximation, which is what the code computes (not the exact erf form).
visualize() returns a text listing of nodes/edges; visualize_dot() returns a Graphviz DOT string. Neither writes a file or needs Graphviz.

Verification: installed the package in a separate venv and ran each method, checking forward values and gradients (e.g. tanh, leaky_relu, gelu on small inputs with backward()), and printed the output of both visualize methods to confirm the descriptions. The existing test suite passes (22 tests). Line endings (CRLF) are preserved.

Left out: grad_check(). It is defined twice in leanpass/tensor.py and the behaviour is the subject of #8, so I did not document it here. That is why this uses Refs #4 instead of closing the issue. The sum()/mean() text is untouched (#5).

Add the missing entries to the Tensor API reference, based on the
current behaviour in leanpass/tensor.py. gelu is documented as the tanh
approximation that the code uses. grad_check is not covered here because
it is defined twice in tensor.py and its behaviour is tracked in Terminay#8.

Refs Terminay#4
@Terminay

Copy link
Copy Markdown
Owner

Looks good to me. Very nicely done and left out the appropriate part!

@Terminay
Terminay merged commit 61caae7 into Terminay:main Oct 26, 2026
3 checks passed
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.

2 participants