Spaces:
Running
Running
Download teaching_examples.py from simon-clmtd/autodiff-visualizer: direct link, hf CLI and curl.
- Browser
- Download file 521 Bytes
-
https://huggingface.co/spaces/simon-clmtd/autodiff-visualizer/resolve/main/teaching_examples.py
- Command line
-
hf download hf://spaces/simon-clmtd/autodiff-visualizer/teaching_examples.py
-
curl -L -o teaching_examples.py https://huggingface.co/spaces/simon-clmtd/autodiff-visualizer/resolve/main/teaching_examples.py
521 Bytes
| """Shared, evaluated teaching examples for legends and visual grammar help.""" | |
| from functools import lru_cache | |
| def multiplication_example(forward_only=False): | |
| import sympy as sp | |
| from autodiff_visualizer import ComputationGraph, safe_parse_expr | |
| graph = ComputationGraph().build(safe_parse_expr('(x*x)*y'), forward_only=forward_only) | |
| graph.evaluate({sp.Symbol('x'): 3., sp.Symbol('y'): 4.}, forward_only=forward_only) | |
| return graph.to_computation_model(forward_only=forward_only) | |