Machine Learning in Elixir (Pragmatic Bookshelf)

PragmaticBookshelf
Leverage Elixir and the Nx ecosystem to build intelligent applications that solve real-world problems in computer vision, natural language processing, and more.

Sean Moriarity @seanmor5

edited by Tammy Coron @Paradox927

Stable Diffusion, ChatGPT, Whisper—these are just a few examples of incredible applications powered by developments in machine learning. Despite the ubiquity of machine learning applications running in production, there are only a few viable language choices for data science and machine learning tasks. Elixir’s Nx project seeks to change that. With Nx, you can leverage the power of machine learning in your applications, using the battle-tested Erlang VM in a pragmatic language like Elixir. In this book, you’ll learn how to leverage Elixir and the Nx ecosystem to solve real-world problems in computer vision, natural language processing, and more.

The Elixir Nx project aims to make machine learning possible without the need to leave Elixir for solutions in other languages. And even if concepts like linear models and logistic regression are new to you, you’ll be using them and much more to solve real-world problems in no time.

Start with the basics of the Nx programming paradigm—how it differs from the Elixir programming style you’re used to and how it enables you to write machine learning algorithms. Use your understanding of this paradigm to implement foundational machine learning algorithms from scratch. Go deeper and discover the power of deep learning with Axon. Unlock the power of Elixir and learn how to build and deploy machine learning models and pipelines anywhere. Learn how to analyze, visualize, and explain your data and models.

Discover how to use machine learning to solve diverse problems from image recognition to content recommendation—all in your favorite programming language.


Sean Moriarity is author of Genetic Algorithms in Elixir: Solve Problems using Evolution, co-creator of the Nx library, and creator of the Axon deep learning framework. Sean’s interests include mathematics, machine learning, and artificial intelligence.


Don’t forget you can get 35% off with your Devtalk discount! Just use the coupon code “devtalk.com" at checkout :+1:

Latest Threads About This Book Top

dmitrykleymenov
@seanmor5 For now avg_loss is counting like {loss, params} -> {batch_loss, new_params} = step(params, x, y) avg_loss = Nx.add(Nx....
New
code-of-kai
@seanmor5 Location: In Chapter 1, on page 14 Description: While attempting to cast the species column to a category in normalized_iris,...
New
bosko
@seanmor5 Definition of batch function in the Data module line |> Stream.chunk_every(batch_size, :discard) should be |> Stream....
New
ahamez
Hello @seanmor5 , When upgrading Axon to 0.7, evaluation fails with: ** (ArgumentError) argument at position 3 is not compatible with c...
New
CoderDennis
When training the cnn_model, I get the following output: Epoch: 0, Batch: 150, accuracy: 0.4985513 loss: 7.6424022 Epoch: 1, Batch: 163,...
New
daneroo
Machine Learning in Elixir: Code Repository Can we get a link to a GitHub repository with all erratas for the examples patched, Then we...
New
hugobarauna
@seanmor5 Instead of https://github.com/jonathanklosko/meow it’s https://github.com/jonatanklosko/meow
New
shaolang
@seanmor5 Test data should be scaled using the learned parameters from scaling train data. For example, if train data contains [1, 2, 3,...
New
zacksiri
@seanmor5 When I try the Nx.Random.uniform_split(new_key, split: {}) function in page 130 I got an undefined function error ** (Undefin...
New
glappen
@seanmor5 I am enjoying the book so far, but ran into an Elixir error on the last example in chapter 1: In my last Livebook cell I have...
New

Most Active This Week Top

Most Active This Month Top

dmitrykleymenov
@seanmor5 For now avg_loss is counting like {loss, params} -> {batch_loss, new_params} = step(params, x, y) avg_loss = Nx.add(Nx....
New

Most Active This Year Top

PragmaticBookshelf
Leverage Elixir and the Nx ecosystem to build intelligent applications that solve real-world problems in computer vision, natural languag...
New
SlowburnAZ
Getting an error when installing the dependencies at the start of this chapter: could not compile dependency :exla, "mix compile" failed...
New
ahamez
Hello @seanmor5 , When upgrading Axon to 0.7, evaluation fails with: ** (ArgumentError) argument at position 3 is not compatible with c...
New
augusto1024
I’m going through the MLP Livebook for identifying cats and dogs, and after training the MLP model and testing it, I get an accuracy of 4...
New
pieteeken
Comments to Chapter 11 version B 3.0 @seanmor5 The dependencies from chapter 11 gave errors on 10 march 2024. I followed the advices...
New
glappen
@seanmor5 I am enjoying the book so far, but ran into an Elixir error on the last example in chapter 1: In my last Livebook cell I have...
New
zacksiri
@seanmor5 When I try the Nx.Random.uniform_split(new_key, split: {}) function in page 130 I got an undefined function error ** (Undefin...
New
jshprentz
The model training loop on page 273 should visualize the model output after each epoch. Instead, an argument error is reported after the ...
New
code-of-kai
@seanmor5 Location: In Chapter 1, on page 14 Description: While attempting to cast the species column to a category in normalized_iris,...
New
daneroo
Machine Learning in Elixir: Code Repository Can we get a link to a GitHub repository with all erratas for the examples patched, Then we...
New
shaolang
@seanmor5 Test data should be scaled using the learned parameters from scaling train data. For example, if train data contains [1, 2, 3,...
New
hugobarauna
@seanmor5 Instead of https://github.com/jonathanklosko/meow it’s https://github.com/jonatanklosko/meow
New
bosko
@seanmor5 Definition of batch function in the Data module line |> Stream.chunk_every(batch_size, :discard) should be |> Stream....
New
CoderDennis
When training the cnn_model, I get the following output: Epoch: 0, Batch: 150, accuracy: 0.4985513 loss: 7.6424022 Epoch: 1, Batch: 163,...
New

Most Active Last Three Years Top

PragmaticBookshelf
Author Spotlight: Sean Moriarity @seanmor5 Machine learning sounds both magical and difficult, but with the right tools and the right...
New
martincabrera
@seanmor5 The mutate macro from the Explorer.DataFrame variable does not like variables: It works without the variable:
New
bdarla
Running the code snippet of Chapter 2 on page 44 of version B1.0, I get the following error: Evaluation process terminated - an exceptio...
New
pieteeken
@seanmor5 Title: Machine Learning in elixir: Some problems with chapter 7 in Version B2.0 On 3 january 2024 I downloaded the Cats & ...
New
eeide
Some minor nits in the beta version: “but is often considered it’s own type of machine learning.” → should be “its” “represents a d...
New
jakesgordon
@seanmor5 I don’t know if there’s much you can do about it, but the SSL certificate for the Wine dataset from archive.ics.uci.edu has an...
New
justincjohnson
@seanmor5 In chapter 1, the accuracy of the model is 0.9666666. On my laptop I only get an accuracy of 0.5333333. Is that a problem? ...
New
sdball
Title: Machine Learning in Elixir: Chapter 1 Example: Flower classification - final accuracy on the test data is inconsistent. When com...
New
polmiro
@seanmor5 the code provided I am running into an error when training the first model that uses transfer learning with ONNX model mobilen...
New
shawn_leong
Hey @seanmor5, I’m having great training accuracy but poor evaluation accuracy for the example in Chapter 1 when following the code in t...
New
haubie
@seanmor5 For Explorer.Query to access variables defined outside of the query ^ must be used. Updated in the example below: cols = ~w(...
New
egutter
Hi, When running tensor = Nx.random_uniform({1_000_000}) There’s a warning message warning: Nx.random_uniform/1 is deprecated. Use Nx....
New
adamt
@seanmor5 Title: Machine Learning in Elixir (epub so pages different i think) From book: Current output: Diff: inputs: %{"ir...
New
simple
Page 226 Mix install uses older versins of exla, should 0.6 to work with cuda120 Page 230 targets pipeline in Data module misses |>...
New
New

Most Active Over Three Years Top

egutter
Version: B1.0 On page 104 the code: Scholar.Metrics.confusion_matrix(test_targets, test_preds) throws an error: required :num_classes ...
New
pieteeken
@seanmor5 Machine Learning in Elixir Some remarks on chapter 8 version B2.0 seanmor5 page 177 It is already mentioned here: :discar...
New
shawn_leong
Hey @seanmor5 , Similar to the errata on deprecation on page 44, on page 128: Nx.random_uniform({}) |> NeuralNetwork.predict(w1, b1,...
New
Chris660
This didn’t seem right to me: For instance, you can squeeze the values of a feature between 0 and 1 by dividing every individual featur...
New
shawn_leong
Hey @seanmor5, The function given in the book defn profits(trees) do trees |> Nx.pow(4) |> Nx.negate() |> Nx.add(Nx.mu...
New
sabiwara
Hello @seanmor5! Thanks a lot for the amazing book and new chapter :purple_heart: I got a couple of errors when trying to run the exampl...
New
yannvery
Version: B1.0 On page 100 (epub version) the code: model = Scholar.Clustering.KMeans.fit(train_inputs, ​num_clusters:​ 3) throws an er...
New
egutter
Version: B1.0 On page 103 & 104 where the code example is: Scholar.Linear.LogisticRegression.fit( train_inputs, train_targets, num_...
New
shawn_leong
Hey @seanmor5, On page 109: model = Scholar.Clustering.KMeans.fit(train_inputs, num_clusters: 3) results in an UndefinedFunctionError....
New
etnt
Title: Machine Learning in Elixir: Learning to Learn with Nx and Axon (6) “You will sometimes see surprising due to precision issues.” ...
New
egutter
Version: B1.0 TL;DR: In page 98 should say two instead of three tensors: Where it says Next, you create three random normal tensors: ...
New
froucoux
“You will sometimes see surprising … due to precision issues.” Missing word, maybe “consequences” or “effects” ? Thanks for the great j...
New
bobek
Examples in GradFun module will show the following warning with Nx 0.5.3 warning: Nx.Defn.Kernel.inspect_expr/1 is deprecated. Use print...
New
grossvogel
The calculation of average loss doesn’t seem right to me: avg_loss = Nx.add(Nx.mean(batch_loss), loss) |> Nx.divide(j + 1) I believe...
New
New

Book Info

Publisher: Pragmatic Bookshelf

Are you this book's author? To be notified of all posts made about it, sign up an account then click here, then select 'watching' from the bell icon in the top right corner.

Get money off!

The Pragmatic Bookshelf

35% off any eBook

Simply use coupon code "devtalk.com" at checkout. See full details here.