An open API service indexing awesome lists of open source software.

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

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`.