Talk: 17:00–17:45 (English)
Type-safe tensors to help human learning
The field of machine learning often grabs Python and its pytorch library as default for both education and real industry projects, due to the perceived language friendliness and the ability to run on GPU hardware. However, the inability to track tensor dimensions and data types has resulted in most practical code being littered with comments that (hopefully) explain the current shape of the calculation. We should be able to do better.
In this presentation, we start with an introduction to tensors and the role they play in machine learning. We then present an approach that uses the Scala type system to track all dimensions, the data type, and device of a pytorch tensor. We will show concepts like matrix multiplication and broadcasting rules applied in a type-safe manner, and show how to refer to specific dimensions by their type, rather than index, all while preserving the same GPU performance that pytorch normally offers.
We will then show a typical “transformer” neural network architecture, and discuss how having strong types improves discoverability of code tremendously. We will also see nice examples of scala-specific syntax improving legibility of neural network code even further.
Jan Ypma
Jan Ypma is an independent software architect and coach, which specializations in distributed systems, the JVM, functional programming, open source, and Domain-Driven Design. His broad experience across technologies, sectors and company sizes gives him a creative approach to finding solutions, using a blend of people and technology. This is further fueled by personal interests in home automation and modular synthesizers. He is a regular conference speaker and facilitator.