Swiftpack.co - Package - dmlc/MXNet.jl


Build Status Windows Build codecov.io MXNet License Join the chat at https://gitter.im/dmlc/mxnet

MXNet.jl is the dmlc/mxnet Julia package. MXNet.jl brings flexible and efficient GPU computing and state-of-art deep learning to Julia. Some highlight of its features include:

  • Efficient tensor/matrix computation across multiple devices, including multiple CPUs, GPUs and distributed server nodes.
  • Flexible symbolic manipulation to composite and construct state-of-the-art deep learning models.

The current support julia version is 0.6. Julia 0.7/1.0 is not supported yet.

Here is an example of how training a simple 3-layer MLP on MNIST looks like:

using MXNet

mlp = @mx.chain mx.Variable(:data)             =>
  mx.FullyConnected(name=:fc1, num_hidden=128) =>
  mx.Activation(name=:relu1, act_type=:relu)   =>
  mx.FullyConnected(name=:fc2, num_hidden=64)  =>
  mx.Activation(name=:relu2, act_type=:relu)   =>
  mx.FullyConnected(name=:fc3, num_hidden=10)  =>

# data provider
batch_size = 100
include(Pkg.dir("MXNet", "examples", "mnist", "mnist-data.jl"))
train_provider, eval_provider = get_mnist_providers(batch_size)

# setup model
model = mx.FeedForward(mlp, context=mx.cpu())

# optimization algorithm
# where η is learning rate and μ is momentum
optimizer = mx.SGD(η=0.1, μ=0.9)

# fit parameters
mx.fit(model, optimizer, train_provider, n_epoch=20, eval_data=eval_provider)

You can also predict using the model in the following way:

probs = mx.predict(model, eval_provider)

# collect all labels from eval data
labels = reduce(
  copy(mx.get(eval_provider, batch, :softmax_label)) for batch ∈ eval_provider)
# labels are 0...9
labels .= labels .+ 1

# Now we use compute the accuracy
pred = map(i -> indmax(probs[1:10, i]), 1:size(probs, 2))
correct = sum(pred .== labels)
accuracy = 100correct/length(labels)
@printf "Accuracy on eval set: %.2f%%\n" accuracy

For more details, please refer to the documentation and examples.


Stars: 324
Help us keep the lights on


Used By



v0.3.0 - Nov 16, 2017

  • Bump libmxnet to

    • On Linux/macOS: v0.12.1
    • On Windows: V0.12.0
      • For GPU version, please install CUDA 8.0; CUDA 9.0 is not supported in this version.
  • Drop Julia 0.5 support

  • Lots of NDArray and SymbolicNode API changes

Please checkout NEWS for more information.

v0.2.3 - May 31, 2017

  • Update to MXNet 0.10.0

v0.2.2 - May 14, 2017

  • Updated supported version of MXNet to 0.9.4.
  • Improved build-system with support for auto-detecting GPU support.
  • Several updates to Metrics.
  • CI for Windows.
  • Verbosity option for predict (@rdeits)

v0.2.1 - Jan 29, 2017

  • Disables setupenv.cmd because it is more invasive then we need it to be.

v0.2.0 - Jan 28, 2017

  • Drop support for Julia v0.4.
  • Added support for NVVM.
  • Updated supported version of MXNet to 0.9.3.
  • New optimizers (@Arkoniak).