Slap/Slurn : Scala Learning and Algebra

Overview

Support for this project is discontinued. It is not compatible with the latest versions of Scala.

A collection of tools for machine learning (BSD License) written in the programming language Scala. Includes plain old Back-propagation, RBMs and Contrastive Divergence.

The Framework consists of 3 Scala libraries built with Maven :

  • Toolbox : useful stuff that doesn’t fit anywhere.
  • Slap (Scala Linear Algebra Package) : matrix manipulation.
  • Slurn (Scala Learning) : pure machine learning stuff goes here.

You can use these libraries as Jars (see Jar files) or install them in you maven repository (see Maven repository).

Installation instructions

Download the 3 maven packages (toolbox, slap and slurn) and pick one of the two installation methods below.

Method 1: Jar files

The jar files can be generated by running mvn package from the root of each project directory. Once the build is completed, the jar can be found in the ”’target”’ directory.

Method 2: Maven repository

run mvn install for the three libraries to install them into your maven repository.

For instance:

User manual

At this point, it is assumed that you have a working installation with the packages toolbox, slap and slurn in available in your classpath.

Toolbox package

Concurrency

This section describes concurrency for version 0.1 not 0.2 and as such only gives a general idea of concurrency features in version 0.2.

Preparation

In order to use the module, you just need to import all functions in the Concurrency object:

In all the following constructs, you are responsible of ensuring that the concurrent parts of your program are thread safe.

Concurrent Blocks

The two blocks { instructions 1 } and { block 2 } are executed concurrently. The “andWait” is optional and can be used to indicate that we want the main thread to wait until the two blocks have ended their computation.

There can be as many blocks as needed in this construct:

Concurrent execute

This construct allows you to call a function concurrently for elements of a sequence. For instance, concurrentlyIn (1 until 5) execute { i => println(i) } will print the integers from 1 to 4 concurrently.

Because using integers is very frequent, you can directly give the lower and uper bound as in

Each time you call concurrentlyIn, Concurrency.numberOfthreads threads will be created to execute the task. By default, this number of threads is the number of processors but you can change it to your convenience.

this code will use 4 threads.

Concurrent enqueue

In many cases, the above construct is not optimal. If you call it multiple times, new threads are created each time. Instead you can enqueue operations in a thread pool.

Slap package

Working with matrices

Example : Matrix creation

Slurn package

Package overview

class diagrams for algorithms and models

RBMs

ANNs and backprop

DBNs

Files