Join 10350+ others. No spamming.
I promise!

Follow us at github.



hshindo / Merlin.jl


Flexible Deep Learning Framework in Julia


This is alpha version, but the examples are working.

Merlin: deep learning framework in Julia

Merlin is a deep learning framework written in Julia.

It aims to provide a fast, flexible and compact deep learning library for machine learning. Our primary goal is to develop a natural language processing toolkit based on Merlin.

Merlin is tested against Julia 0.5 on Linux, OS X, and Windows (x64).

Build Status Build status



  • Julia 0.5 or later
  • g++ (for OSX or Linux)


First, install Julia. Currently, version 0.5 is supported.

Then, clone and build the package.

julia> Pkg.clone("")

To run the Merlin examples, add MLDatasets package:

julia> Pkg.clone("")

which provides an access to common machine learning datasets.

Quick Start


  1. Wrap your data with Var or zerograd.
  2. Apply functions to Var. Var memorizes a history of functional applications for auto-differentiation.
  3. Compute gradients if necessary.

Here is an example of three-layer network:

using Merlin

T = Float32
x = zerograd(rand(T,10,5)) # initialize Var with zero gradient
y = Linear(T,10,7)(x)
y = relu(y)
y = Linear(T,7,3)(y)


If you don't need gradients of x, use x = Var(rand(T,10,5)).

When you apply Var() to a function, it's lazily evaluated.

T = Float32
x = Var()
y = Linear(T,10,7)(x)
y = relu(y)
y = Linear(T,7,3)(y)
@assert == nothing

f = compile(y, x) # output: y, input: x
x = zerograd(rand(T,10,10))
y = f(x)

where compile(y, x) compiles the network structure from output variable: y and input variable: x, and create a Graph object. When the network structure is static, it is recommended to use this style.

More examples can be found in examples.


Common datasets are available via MLDatasets.jl.