https://github.com/ndrean/linear_regression_nx_axon
Linear Regressions with Nx, matrices, gradient descent, Neural Network with Axon
https://github.com/ndrean/linear_regression_nx_axon
axon elixir nx
Last synced: 6 months ago
JSON representation
Linear Regressions with Nx, matrices, gradient descent, Neural Network with Axon
- Host: GitHub
- URL: https://github.com/ndrean/linear_regression_nx_axon
- Owner: ndrean
- Created: 2023-01-11T09:44:45.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-11-15T09:26:16.000Z (almost 2 years ago)
- Last Synced: 2025-02-06T06:46:16.132Z (8 months ago)
- Topics: axon, elixir, nx
- Homepage:
- Size: 31.3 KB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# linear_regression_nx_axon
Goal: learning a bit of `Nx`, numerical functions with `defn` and `Axon`, and how to use `Livebook` and `Vegalite` by playing with linear regression.
I take a "straightforward" model made of points in the form `(i, i+:rand.uniform)` in a range `1..50`.
I want to find the coefficients of the best linear fit to this set.I start by calculating the exact solution with `Nx` matrices, in other words by playing with tensors, `transpose` and `LinAlg.inverse`.
Then I use statistical formulas to run this calculations.Then approaching the solution with a gradient descent. This time, I use the `.grad` macro.
Some graphics are added to understand the importance of coefficients.Finally, a first encounter with `Axon` by using the most basic Neural Network. The activation is `:linear` and the loss is `: mean_squared_error`. It is important to use `compile: EXLA`.