Nx Course




What's in this preview?

We want you to get the feel for typical Groxio content and the reasons we provide each type of content. Each Groxio module comes in four scheduled releases consisting of the central PDF, videos, and resource links. Later releases have projects as well. You can see part of the first release here.

Numerical Computing for Elixir



Buy Course Today!



Preview PDF!



Preview Epub!




Release Schedule: 2021-09-01 through 2021-11-08

Version: Oct 18, 2021


Just $70.00, A La Carte
(other options available)




Programmer Passport Nx






Why a book?

The scientific teaching method we follow is the Dreyfus learning model. Books provide the metaphors experts need to build context, step-by-step instructions for beginners, and the exercises that intermediates need to learn.

Itinerary


1. Design and Setup

2. A linear regression

3. Axon Basics

4. Axon CNNs

Why an itinerary?

The itinerary is a virtual guide. This optional list describes the highlights of each release to maximize your learning time.

Description

Nx is a library for building numerical computing applications, the so-called STEM applications, in Elixir. Rather than using basic Elixir numeric datatypes and lists, Nx uses tightly integrated pluggable backends to implement support for efficient types and structures. The result is a seamless and smooth experience.


The Nx project already has an impressive list of smaller projects underway. The LiveBook takes advantage of Phoenix LiveView and Nx to provide a place to collaboratively share research projects with data, code, and prose. The EXLA project provides support for Google’s excelerated linear algebra within a LiveBook. Compiler support and backends provide tight integration to efficient STEM libraries in other langauges.

History

Nx has been around a short time. In 2020, Sean Moriarity was working on Genetic Algorithms in Elixir. He was using several techniques to do ad-hoc machine learning in Elixir. José Valim, creator of Elixir, connected with him in late 2020 to explore building a robust library for numerical computation. Together, they built the core of Nx and Axon. The project has rapidly made progress with the introduction of LiveBook, and the number of contributors has steadily grown, but the project is still in its infancy.




Course Objectives

Over the course of this module, you’ll learn the core abstractions of Nx. Rather than drilling you on the various internal functions that make up the Nx API, you’ll learn the basic core abstractions for working with tensors on backends in Nx, share your work with live plots in a LiveBook, and use those concepts in the context of the Axon machine learning library.


When you’re done, you’ll be able to:


  1. Create, manipulate, shape, and name multi-dimensional data in tensors.

  2. Work with Nx using alternative backends.

  3. Write your own tensor-aware custom code with numeric definitions, and use transformations to broadcast to tensors so that you can tell if two tensors are compatible.

  4. Work with plots within a LiveBook, and use those plots to communicate your results to others.

  5. Build, train, and save Axon models to solve your own machine learning problems.

  6. Understand new Axon models as they emerge.

Videos

Public & Private




Why videos?

Groxio language modules have two kinds of videos. Our overview videos set the history and context of a language, or wrap up the work we've done, and are free to support language ecosystems. Our coding instruction videos, mostly starting with the second release, are paid content, and each one offers a live coding project.

Every learning level benefits from pair programming. Our videos are professional, but do not scrub away every tiny mistake. That way, you can see how experienced programmers deal with errors and changes in code organization.

1. Elixir Axon: A FizzBuzz Demo

Elixir's Nx is a numerical computing library for Elixir. This video is a demo showing where this course will be going over three months. We'll start with Nx and the primitives, explore tensors in the context of a LiveBook, and then shift to using Nx in practice with the Axon machine learning library.

2. Nx: Overview and Creating Tensors

Elixir's Nx library is fundamentally about creating tensors. This video will provide an overview of the Nx umbrella project and walk through the basics of creating tensors and using them in operations. We'll look at the primitives that create tensors, their components, and how to manipulate them.

Video

3. Nx: Numerical Definitions and defn

Mathematical functions in numeric computing often require formulas that must interact with tensors using the basic rules of linear algebra. Nx provides numerical definitions for that purpose. These functions replace pure Elixir primitives with tensor-aware alternatives.
Subscriber content

Video

4. Nx: Broadcasting Compatible Tensors

Often when you work with tensors, you must make two tensors with similar shapes interact. Nx has an operation called a broadcast that makes the shapes of two similar tensors match. To understand how operators work in Nx, you must understand broadcast.
Subscriber content

5. Nx: Ways to Create Tensors

Nx developers typically use alternative functions to the usual Elixir functions that manipulate enumerables. Learning these functions will help you navigate Nx quickly because they are more performant and concise than the typical Elixir alternatives.

Video

6. Nx: Slicing Tensors to Access Data

Accessing data in a tensor is not always as easy as providing indexes in multiple dimensions. This video explores slicing in the context of a LiveBook. Ranges and named axes are critical techniques you'll learn in this brief exploration of Nx basics.
Subscriber content

7. Elixir Nx Dot Products

Dot products are foundational operators for working with tensors. In Nx, dot products are tensor-aware functions. This video will walk you through the linear algebra basics, and how the function works in the context of an Elixir Nx application.

Video

8. Elixir Nx Dot Product Intuition

Dot products are easy to describe mathematically, but they are confusing. In this video, we help you build your intuition for what is actually going on. Because dot products in machine learning models use matrices, it's important to understand what types of data a matrix might store, and how to strike relationships between them.
Subscriber content

Video

9. Linear Regression Intuition

Linear regressions are a statistical approach that uses calculus to solve systems of equations. Given several data observations, they start with a line predicting a solution, and then improve the line bit by bit until they make close preditions to real-world observations. This video helps you understand how they work.
Subscriber content

10. Nx Linear Regression: Loss and Predictions

Linear regressions use prediction functions and loss functions to make basic predictions, and then seek to minimize loss, one small step at a time. This video builds the code that implements the initial loss and prediction functions we'll use in the training process later in the series. Thanks to Sean Moriarity for the initial code.

Video

11. Nx Training Functions for a Linear Regression

Linear regressions make an initial random prediction, and incrementally improves it in the process of training. This video builds a batched training process with several passes, called epochs, to iteratively train a model using Elixir's Nx.
Subscriber content

Video

12. Elixir NX: Writing a Training Script for a Linear Regression

Training a model using machine learning techniques requires batches of training and test data. In this video, we build a script to generate training data and test the performance of the model before and after training based on an objective loss function.
Subscriber content

13. Axon Models

Axon models are functions with special properties. They are parameterized, so they can be tweaked to change their behavior. They are layered into composable Elixir pipe segments. They are also made up of tensors so they take tensors as inputs and return tensors as outputs. This video shows how models work.

Video

14. Axon Data

As we build our Axon training projects, we'll capture some training data, then we'll tweak the model until it returns values as close as possible to our training data. We'll also capture some test data so that we can make sure our trained models perform well. This section is on preparing data.
Subscriber content

15. Axon Interpretation of Predictions

Axon models are probalistic, so they return probabilities of certain categories. In this section, we use predefined labels and translate categorical probabilities to user-friendly labels so we can quickly understand what a model is showing us.

Video

16. Axon Build a FizzBuzz Model

The Axon training system takes a model (a parameterized function), some data inputs, and some outputs. This video shows how models work by digging a little under the surface of the model. Then, we use the model to make some basic predictions.
Subscriber content

Video

17. Axon Training

The Axon training system takes a model (a parameterized function), some data inputs, and some outputs. Then, it tweaks the parameters in the model until the model's predict function returns what we want it to. In this section, we write the code for an Axon training process.
Subscriber content

Community Resources

Cool quick trips for Nx




Why resource links?

Each new chapter has a set of links, separated into three categories. The categories reflect different competency levels and resources that match that stage of learning, for each Groxio release.

Learn It

These resources will get you on the path to learning with background information, tooling and exercises.

Do It

You decide how deep to go. These resources are exercises and projects to cement your learning.

Grok It

These resources will help you put your new knowledge into context so you'll be better at your everyday job.

Projects

Longer Excursions (chapters 3 and 4)






Why projects?

The Dreyfus model is originally instruction for pilots. A typical pilot course is based on reading material to understand context, and then flying a plane. Our videos and PDFs are important, but in the end, programmers need to program in order to learn. Our projects offer different levels of assistance, from "give me the answer" to "make this test pass".