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

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

I wish you a great day! :rainbow:

21 Likes

Nice one Nick! Do you think (with your work) it’s a good book for Elixir users? Is it an easy read? If so maybe we should run a book club on it :sunglasses:

Paolo Perrotta is a great author - he wrote one of my favourite Ruby books: Metaprpogramming Ruby! Here’s my recollection of it in his spotlight on DT:

2 Likes

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:

3 Likes

@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:

3 Likes

Welcome @shawn_leong ! And thanks for the kind words, really appreciated! :smiling_face:

found it easier to understand nx/axon it after I understood the analogous libraries in Python.

Indeed, knowing a bit of numpy and Keras (which are used in the book) can be really helpful to understand Nx/Axon and navigate their APIs.
I didn’t have any experience in ML before reading the book and i never used these python libraries as well (numpy yes, but for other stuff), therefore in some cases I needed to figure out which API to use/compose together the reach the same result illustrated in the book, especially in the first chapters. For instance, my first implementation to initialize the weights with zeroes was:

# Given n elements it returns a tensor
# with this shape {n, 1}, each element
# initialized to 0
defp init_weight(x) do
  n_elements = elem(Nx.shape(x), 1)
  Nx.tile(Nx.tensor([0]), [n_elements, 1])
end

Then, later on I switched to this one which I believe is more correct:

# Given n elements it returns a tensor
# with this shape {n, 1}, each element
# initialized to 0
defnp init_weight(x) do
  Nx.broadcast(Nx.tensor([0]), {elem(Nx.shape(x), 1), 1})
end

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

yes please, I’d love them :heart:

Cheers :v:

2 Likes