• Stars
    star
    22
  • Rank 1,014,648 (Top 21 %)
  • Language
    Crystal
  • License
    Other
  • Created about 5 years ago
  • Updated almost 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

MXNet (AI/ML) bindings for the Crystal language.

Deep Learning for Crystal

GitHub Release Build Status Documentation

MXNet.cr provides MXNet bindings for the Crystal programming language. MXNet is a framework for machine learning and deep learning written in C++, supporting distributed training across multiple machines and multiple GPUs (if available).

MXNet.cr follows the design of the Python bindings, albeit with Crystal syntax. The following code:

require "mxnet"
a = MXNet::NDArray.array([[1, 2], [3, 4]])
b = MXNet::NDArray.array([1, 0])
puts a * b

outputs:

[[1, 0], [3, 0]]
<NDArray 2x2 int32 cpu(0)>

Examples

If you want to see what MXNet.cr can do, check out toddsundsted/deep-learning. It is a collection of problems and solutions from Deep Learning - The Straight Dope, a set of notebooks teaching deep learning using MXNet.

Installation

MXNet.cr requires MXNet.

Build MXNet from source (including Python language bindings) or install the library from prebuilt packages using the Python package manager pip, per the MXNet installation instructions:

https://mxnet.incubator.apache.org/install/index.html

And add the following to your application's shard.yml:

dependencies:
  mxnet:
    github: toddsundsted/mxnet.cr

Troubleshooting

MXNet.cr relies on the Python library to find the installed MXNet shared library ("libmxnet.so"). You can verify MXNet is installed with the following Python code:

import mxnet as mx
a = mx.ndarray.array([[1, 2], [3, 4]])
b = mx.ndarray.array([1, 0])
print(a * b)

which outputs:

[[1. 0.]
 [3. 0.]]
<NDArray 2x2 @cpu(0)>

OSX

On OSX, you may need to give your program a hint about the location of the MXNet shared library (libmxnet.so). If you build and run your program and see an error message like the following:

dyld: Library not loaded: lib/libmxnet.so
  Referenced from: /Users/homedirectory/.cache/crystal/crystal-run-eval.tmp
  Reason: image not found

you need to either: 1) explicitly set the DYLD_FALLBACK_LIBRARY_PATH environment variable to point to the directory containing libmxnet.so, or 2) move or copy libmxnet.so into a well-known location (such as the project's own lib directory).

Alternatively, and more permanently, you can modify the libmxnet.so shared library so that it knows where it's located at runtime (you will modify the library's LC_ID_DYLIB information):

LIBMXNET=/Users/homedirectory/mxnet-1.5.1/lib/python3.6/site-packages/mxnet/libmxnet.so # the full path
install_name_tool -id $LIBMXNET $LIBMXNET

Status

MXNet.cr currently implements a subset of Gluon, and supports a rich set of operations on arrays and symbols (arithmetic, trigonometric, hyperbolic, exponents and logarithms, powers, comparison, logical, rounding, sorting, searching, reduction and indexing) with automatic differentiation built in.

Implemented classes:

  • MXNet
    • Autograd
    • Context
    • Executor
    • Optimizer
    • NDArray
    • Symbol
    • Gluon
      • Block
      • HybridBlock
      • Sequential
      • HybridSequential
      • SymbolBlock
      • Dense
      • Pooling
      • Conv1D
      • Conv2D
      • Conv3D
      • MaxPool1D
      • MaxPool2D
      • MaxPool3D
      • Flatten
      • L1Loss
      • L2Loss
      • SoftmaxCrossEntropyLoss
      • Activation
      • Trainer
      • Parameter
      • Constant

More Repositories

1

ktistec

Single user ActivityPub (https://www.w3.org/TR/activitypub/) server.
Crystal
330
star
2

stunt

LambdaMOO with multiple inheritance, anonymous objects, HTTP, JSON <-> MOO translation, better crypto, a map datatype and a RESTful interface.
C++
72
star
3

ishi

Graph plotting package with a small API and sensible defaults powered by gnuplot.
Crystal
47
star
4

improvise

Starter kit for Stunt.
JavaScript
18
star
5

rmoo

A major mode for interacting with MOOs.
Emacs Lisp
12
star
6

Public-Suffix-List

Ruby code for working with the Public Suffix List
Ruby
11
star
7

deep-learning

Exercises in deep learning -- Crystal language edition
Crystal
10
star
8

web_finger

A WebFinger (https://tools.ietf.org/html/rfc7033) client for Crystal.
Crystal
9
star
9

jquery.tweetcapture

Capture Twitter search tweets in real time and stick them in a web-page.
JavaScript
7
star
10

iterm2

Display images within the terminal using the ITerm2 Inline Images Protocol.
Crystal
6
star
11

slang

Slim-inspired templating language for Crystal
Crystal
5
star
12

host_meta

A Web Host Metadata (https://tools.ietf.org/html/rfc6415) client for Crystal.
Crystal
3
star
13

shiken

Basic Rails and Git skills test for candidates.
Ruby
3
star
14

javascript-as3-socket

Git clone of http://code.google.com/p/javascript-as3-socket/ with improvements.
JavaScript
3
star
15

heroku-buildpack-stunt

Heroku buildpack for Stunt.
Shell
2
star
16

openssl_ext

Crystal bindings for OpenSSL RSA
Crystal
2
star
17

ki

A simple mobile agent framework, described in a series of articles for JavaWorld c. 1998.
Java
2
star
18

pwnserver

It's my data and I wants it back!
2
star
19

public_suffix

A small Crystal library designed to make the Public Suffix List (https://publicsuffix.org/) easier to use.
Crystal
2
star
20

compare-cores

Compares two LambdaMOO databases (with extensions).
Perl
2
star
21

moocode-mode

A fork of Rob Myers' Emacs major mode providing syntax highlighting and indentation for MOO code.
Emacs Lisp
2
star
22

rubyweb

Rubyweb - a literate programming system for Ruby
Ruby
1
star
23

zzz

Hypermedia controls.
1
star
24

Scala-for-Scripting

Scala
1
star
25

libxml_ext

Extensions to XML in Crystal.
Crystal
1
star
26

iui

Custom version of the IUI iPhone webapp library.
JavaScript
1
star