NickGnd

NickGnd

Programming Machine Learning (book) - Livebooks with Nx and Axon

Hey all :wave:
I took me a bit more than 1 year but I finally managed to finish “Programming Machine Learning - From Coding to Deep Learning” book and to reproduce all the Python Jupyter notebooks with Nx/Axon of course by running them in Livebook.

Overall, the experience was pretty good. I found the elixir-nx libraries rather stable in terms of APIs even if they are pre 1.0. And when I had doubts or when I stumbled across some potential issues, I’ve reached out for help in Github or here in the forum.

The repository is hosted here :point_right: GitHub - nickgnd/programming-machine-learning-livebooks: Programming Machine Learning - Elixir Livebooks · GitHub

Any suggestion, comment, feedback is welcome. :smiling_face:

I wish you a great day! :rainbow:

Most Liked

NickGnd

NickGnd

Thanks @AstonJ :slight_smile:

Do you think (with your work) it’s a good book for Elixir users? Is it an easy read?

It is definitely a good and well written book, with a practical approach and only a couple of “heavy-math” chapters. In general I liked it and I found it easy to follow, even if I didn’t have much experience with numpy. In the first chapters I struggled a bit to replicate the examples in Nx, but mainly because I was completely new to the library and to the concepts, that’s part of the game.

If so maybe we should run a book club on it

I think it can be a valuable reading if you wanna start with ML, on the other hand, the book is 3 years old and given the pace of innovation in ML, maybe there are more up to date resources out there :thinking: The basis won’t change tho’, but for example I’d have like some chapters on more advanced topics such as NLP, transformers, reinforcement learning (but I guess they deserve a book on their own :grimacing: ).

Paolo Perrotta is a great author - he wrote one of my favourite Ruby books: Metaprpogramming Ruby!

I never read it, but I saw a talk on Git by him once and it was great :slight_smile:

heinsaris

heinsaris

Hi Nick,

Thank you for doing this. It is really great.

I started reading the book, and follow along with your livebooks. I have only just started so I am only at Chapter two at the moment.

By evaluating your code for the Linear Regression example, I noticed that it always goes through all the iterations, whereas the Python code in the book stops when the error is no longer smaller then the previous error.

By using a reduce_while instead of a reduce in the train function, you could mimic that behaviour. Here is how I changed it:

def train(x, y, iterations, lr) when is_list(x) and is_list(y) do
    Enum.reduce_while(0..iterations, 0, fn i, w ->
      current_loss = loss(x, y, w)

      IO.puts("Iteration #{i} => Loss: #{current_loss}")

      cond do
        loss(x, y, w + lr) < current_loss -> {:cont, w + lr}
        loss(x, y, w - lr) < current_loss -> {:cont, w - lr}
        true -> {:halt, w}
      end
    end)
  end

It will then stop at the 184th iteration, just like in the book :slightly_smiling_face:

Regards,

Hein

shawn_leong

shawn_leong

@NickGnd This is so timely & amazing. Thank you.

I’ve tried the Dockyard tutorials at first since I didn’t want to leave Elixir-land but soon found it easier to understand nx/axon it after I understood the analogous libraries in Python.

Be happy to provide feedback on the livebooks as I progress.

Have a great day too :pray:

Where Next?

Popular in Other Resources Top

jramnani
Hello, I am almost done going through the book, Programming Phoenix 1.4, again after a hiatus from using Elixir for a few years. It see...
New
Exadra37
I am building a Tasks Todo app to help me to organize my professional and personal life, while at same time I learn Elixir, and this week...
New
dimitarvp
Hello, While coding tests for a hobby project of mine, I stumbled upon something odd when directly comparing Decimals – which is a bad i...
New
ericdouglas
I’m very happy to launch this project since it is a culmination of several years of a self-knowledge process and acquired experience in s...
New
ErlangSolutions
This month, we’re launching an in-depth 3-part webinar series on API design hosted by Bruce Tate. Bruce’s knowledge of, and love for Eli...
New
zenw0lf
Hello all! I just finished a full step-by-step tutorial on how to build a JSON API with Phoenix: https://lobotuerto.com/blog/building-a...
New
hectorperez
Hi, I found that a great way to learn is: play with existing livebook notebooks create new notebooks — completely new or just changing ...
New
blackode
Elixir Quiz that tests your Knowledge in Elixir Programming. Elixir Functional Programming Test Intermediate level :pen: 30 questions ·...
New
wolfiton
Cool way to learn service workers by playing this game Also this game may not work well in the latest Firefox but works in Opera
New
GenericJam
It seems like most employers want a reasonably high degree of competence before they’re willing to look at a candidate. Perhaps it’s beca...
New

Other popular topics Top

malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36128 110
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 47930 226
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New

We're in Beta

About us Mission Statement