Einops: Powerful library for tensor operations in deep learning | Oxford Protein Informatics Group
Tobias and I recently gave a talk at the OPIG retreat on tips for using PyTorch. For this we created a tutorial on Google Colab notebook (link can be found here). I remember rambling about the advantages of implementing your own models against using other peoples code. Well If I convinced you, einops is for you!! Basically, einops lets you perform operations on tensors using the Einstein Notation. This package comes with a number of advantages a few of which I will try and summarise here: Here are two ways of doing the same operation, one in pure PyTorch and one using einops: While they would both get you to the same place, in the second one you can immediately see that we are grouping the last to dimensions of the tensor x. There are basically only 3 operations in einops (rearrange, reduce, repeat). However, to cover what you can do with these three operations you would need to learn the syntax for tens of functions in PyTorch. For examples on how powerful these are see here. The simp
Tobias and I recently gave a talk at the OPIG retreat on tips for using PyTorch. For this we created a tutorial on Google Colab notebook (link can be found here ). I remember rambling about the advantages of implementing your own models against using other peoples code. Well If I convinced you, einops is for you!! Basically, einops lets you perform operations on tensors using the Einstein Notation. This package comes with a number of advantages a few of which I will try and summarise here: 1. It is easy to understand. Here are two ways of doing the same operation, one in pure PyTorch and one u
Explore this link on the map →related reading
- Einops tutorial, part 1: basics - Einopseinops.rocks
- Einsum is easy and usefulejenner.com
- PyTorch internals : ezyang's blogblog.ezyang.com
- Tim Rocktäschelrockt.ai
- Tim Rocktäschelrockt.github.io
- Chapter 0: Fundamentals - ARENAlearn.arena.education
- Tensors — PyTorch Tutorials 2.12.0+cu130 documentationpytorch.org
- Making Deep Learning go Brrrr From First Principleshorace.io
- PyTorch (@PyTorch) / Xx.com
- Tensor Considered Harmfulnlp.seas.harvard.edu
- Tensors — PyTorch Tutorials 2.13.0+cu130 documentationdocs.pytorch.org
- Computing sharding with einsum : ezyang's blogblog.ezyang.com