Often times you want to slice and index into specific parts of a tensor. Nx offers a few different slicing and indexing routines which allow you to accomplish most of what you would want to do. Slicing can be a bit tricky given static shape requirements, but you usually can work around limitations. First, you … Continue reading Nx Tip of the Week #14 – Slicing and Indexing
Tag: nx
Nx Tip of the Week #9 – Window Functions
With the release of Nx 0.1.0, I thought I should continue these posts. My time is a limited so these will be a little more brief than before. Each week I'll highlight a small aspect of the Nx API with some code examples. When you first get started with an array programming library like Nx … Continue reading Nx Tip of the Week #9 – Window Functions
Nx Tip of the Week #8 – Using Nx.Defn.aot/3
Last week, we discussed the usage of Nx.Defn.jit/3 to JIT compile and run numerical definitions. Nx also supports ahead-of-time compilation using Nx.Defn.aot/3. In this post, we'll briefly look at how to use ahead-of-time compilation, and why you'd want to do it in the first place. Ahead-of-time compilation allows you to compile your numerical definitions into … Continue reading Nx Tip of the Week #8 – Using Nx.Defn.aot/3
Nx Tip of the Week #7 – Using Nx.Defn.jit
There are actually 2 ways in Nx to accelerate your numerical definitions: invoking calls to defn with a @defn_compiler attribute set, or calling Nx.Defn.jit/3. Let's take a look at these 2 methods in practice: defmodule JIT do import Nx.Defn @default_defn_compiler EXLA defn softmax(x) do max_val = Nx.reduce_max(x) Nx.exp(x - max_val) / Nx.sum(Nx.exp(x - max_val)) end … Continue reading Nx Tip of the Week #7 – Using Nx.Defn.jit
Axon: Deep Learning in Elixir
ax·on/ˈakˌsän/nounthe long threadlike part of a nerve cell along which impulses are conducted from the cell body to other cells. Today I am excited to publicly announce Axon, a library for creating neural networks in Elixir. Axon is still pre-release; however, I believe it's reached a point where it's ready for experimentation and input from … Continue reading Axon: Deep Learning in Elixir
Nx Tip of the Week #6 – Compiler or Backend?
I've recently seen some confusion with respect to compilers and backends. This post is intended to clear up some of that confusion. TLDR: If performance matters, benchmark and decide. If you need flexibility or want to prototype quickly and not sacrifice speed, backends are a good choice. If you need AOT compilation or your programs … Continue reading Nx Tip of the Week #6 – Compiler or Backend?
Nx Tip of the Week #5 – Named Tensors
Note: The original named tensors article, Tensor Considered Harmful, goes through these details in much more detail and explains much better than I can. I recommend reading that as well. One of my biggest frustrations when working with NumPy and TensorFlow comes when working with axes. Take for example, this TensorFlow implementation of the Mean … Continue reading Nx Tip of the Week #5 – Named Tensors
Nx Tip of the Week #4 – Using Keywords
Numerical definitions can only accept tensors or numbers as positional arguments; however, you can get around this inflexibility using keyword lists. You can pass and use optional keyword arguments in your numerical definitions with the keyword! method. Let's take a look at some ways this might be useful. Parameter Initializers In many ML applications, you … Continue reading Nx Tip of the Week #4 – Using Keywords
Nx Tip of the Week #3 – Many Ways to Create Arrays*
*tensors In Nx, the fundamental type is the Tensor. You can think of a tensor as a multi-dimensional array, like the numpy.ndarray. For Elixir programmers, it's easy to think of Nx.Tensor as a list, or a list-of-lists, or a list-of-lists-of-lists, ... and so on. This thought process is fine, but it might lead you to … Continue reading Nx Tip of the Week #3 – Many Ways to Create Arrays*
Nx Tip of the Week #2 – Tensor Operations for Elixir Programmers
In Elixir, it's common to manipulate data using the Enum module. Enum provides a set of library functions for working with types that implement the Enumerable protocol. The Enum module is a productive interface for manipulating lists, maps, sets, etc. However, learning how to think about tensor manipulation using Nx can be a bit difficult … Continue reading Nx Tip of the Week #2 – Tensor Operations for Elixir Programmers