torch is an R port of PyTorch, one of the two most-employed deep learning frameworks in industry and research. It is also an excellent tool to use in scientific computations. It is written entirely in R and C/C++.

Though still "young" as a project, R torch already has a vibrant community of users and developers. Experience shows that torch users come from a broad range of different backgrounds. This book aims to be useful to (almost) everyone. Globally speaking, its purposes are threefold:

  • Provide a thorough introduction to torch basics – both by carefully explaining underlying concepts and ideas, and showing enough examples for the reader to become "fluent" in torch
  • Again with a focus on conceptual explanation, show how to use torch in deep-learning applications, ranging from image recognition over time series prediction to audio classification
  • Provide a concepts-first, reader-friendly introduction to selected scientific-computation topics (namely, matrix computations, the Discrete Fourier Transform, and wavelets), all accompanied by torch code you can play with.

Deep Learning and Scientific Computing with R torch is written with first-hand technical expertise and in an engaging, fun-to-read way.

part I|94 pages

Getting Familiar with Torch

chapter 21|2 pages


chapter 2|2 pages

On torch, and How to Get It

chapter 3|26 pages


chapter 4|8 pages


chapter 5|6 pages

Function Minimization with autograd

chapter 6|10 pages

A Neural Network from Scratch

chapter 7|6 pages


chapter 8|12 pages


chapter 9|8 pages

Loss Functions

chapter 10|8 pages

Function Minimization with L-BFGS

chapter 11|4 pages

Modularizing the Neural Network

part II|178 pages

Deep Learning with torch

chapter 96Chapter 12|2 pages


chapter 13|8 pages

Loading Data

chapter 14|14 pages

Training with luz

chapter 15|20 pages

A First Go at Image Classification

chapter 16|16 pages

Making Models Generalize

chapter 17|12 pages

Speeding up Training

chapter 19|20 pages

Image Segmentation

chapter 20|18 pages

Tabular Data

chapter 21|28 pages

Time Series

chapter 22|26 pages

Audio Classification

part III|116 pages

Other Things to do with torch: Matrices, Fourier Transform, and Wavelets

chapter 274Chapter 23|2 pages


chapter 24|28 pages

Matrix Computations: Least-squares Problems

chapter 25|14 pages

Matrix Computations: Convolution

chapter 27|18 pages

The Fast Fourier Transform (FFT)

chapter 28|28 pages