wercker status codecov

View documentation.

Data structures and libraries for Torch. All instances are Torch serializable with and torch.load.


You can install torchlib as follows:

git clone && cd torchlib && luarocks make

Torchlib is namespaced locally. To use it:

local tl = require 'torchlib'

local m = tl.DirectedGraph()

Examples and use cases are shown in the documentation.


The documentation is hosted here. Alternatively you can build your own documentation with docroc, which you can get here.


Torchlib's can be divided into categories based on usecases.

Basic Datastructures and Algorithms

  • Graphs
  • Lists, heaps, queues and stacks
  • Maps and counters
  • Sets
  • Trees

Machine Learning

The machine learning package contains utilities that facilitate the training of and evaluation of machine learning models. These include:

  • Dataset, which provides mechanisms for subsampling, shuffling, batching of arbitrary examples.
  • Vocab, for mapping between indices and words.
  • Model, an abstract class to facilitate the training of Torch based machine learning models.
  • Scorer, for evaluating precision/recall metrics.
  • ProbTable, for modeling probability distributions.
  • Experiment, for logging experiment progress to a postgres instance.


  • Downloader, for downloading content via http.
  • Global, global convenience functions namespaced under tl.
  • String, string convenience functions namespaced under tl.string and monkeypatched into string.
  • Table, table convenience functions namespaced under tl.table and monkeypatched into table.


Pull requests are welcome! Torchlib is unit tested with the default Torch testing framework. Continuous integration is hosted on Wercker which also automatically builds the documentations and deploys them on Github pages (of this repo).