Getting Started With Torch

Posted on June 1, 2016

lua, torch

Introduction

It is a scientific computing framework with wide support for machine learning algorithms that uses GPUs first. It is easy to use, fast scripting language, LuaJIT and an underlying C/CUDA implementation.

some core features available are:

  • a powerful N-dimensional array
  • lots of routines for indexing, slicing, transposing, …
  • amazing interface to C, via LuaJIT
  • linear algebra routines
  • neural network, and energy-based models
  • numeric optimization routines
  • Fast and efficient GPU support
  • Embeddable, with ports to iOS, Android and FPGA backends

Torch comes with a large ecosystem of community-driven packages in machine learning, computer vision, signal processing, parallel processing, image, video, audio and networking among others, and builds on top of the Lua community.

Installing Torch

In Mac OSX, Ubuntu 12+ it can be installed in the home folder in ~/torch by following commands

# in a terminal, run the commands WITHOUT sudo
git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch; bash install-deps;
./install.sh

To uninstall torch, simply run the command:

rm -rf ~/torch

Invoke your shell (bash/zsh) by calling appropriate shell

bash

Type th to invoke torch terminal

th

Example codes

Following are some toy codes to learn torch.