Subscribe Free

Join 2670+ others. No spamming.
I promise!

We are currently under high development. Follow us at github.


Looking for Python Tutorials?
Check these awesome tutorials



hshindo/Merlin.jl

63

hshindo / Merlin.jl

Julia

Flexible Deep Learning Framework in Julia


READ ME

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

Documentation

Requirements

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

Installation

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

Then, clone and build the package.

julia> Pkg.clone("https://github.com/hshindo/Merlin.jl.git")
julia> Pkg.build("Merlin")

To run the Merlin examples, add MLDatasets package:

julia> Pkg.clone("https://github.com/JuliaML/MLDatasets.jl.git")

which provides an access to common machine learning datasets.

Quick Start

Basically,

  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)

gradient!(y)
println(x.grad)

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 y.data == 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.

Datasets

Common datasets are available via MLDatasets.jl.