Nx Tip of the Week #14 – Slicing and Indexing

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

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*