dopt 0.3.0

A numerical optimisation framework


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

dopt

A numerical optimisation and deep learning framework for D.

Current features include:

  • Ability to construct symbolic representations of tensor-valued functions
  • Basic arithmetic and mathematical operations (add, sub, mul, div, abs, log, exp, ...)
  • Basic matrix operations (multiplication, transpose)
  • Reverse-mode automatic differentiation
  • Stochastic gradient descent
  • Neural network primitives
  • Neural network construction utilities
  • Framework to add third party operations and their derivatives, and the ability register implementations for both the CPU and CUDA backends.

The project is still in the early stages, and some things might not work properly yet. Some planned future features include:

  • The ability to add optimisation passes to the CPU and CUDA backends.
  • More sophisticated online optimisation algorithms (SGD+momentum, AdaGrad, ADAM, etc)

Docs

Documentation can be found here.

Using

The easiest way to use dopt is by adding it as a dependency in your project's dub configuration file. See dub's getting started page for more information about how to do this.

Example

See examples/mnist.d for the full code.

void main(string[] args)
{
    import dopt.core;
    import dopt.nnet;
    import dopt.online;

    auto data = loadMNIST(args[1]);

    auto features = float32([100, 1, 28, 28]);
    auto labels = float32([100, 10]);

    auto layers = dataSource(features)
                    .convolutional(32, [5, 5])
                    .relu()
                    .maxPool([2, 2])
                    .convolutional(32, [5, 5])
                    .relu()
                    .maxPool([2, 2])
                    .dense(10)
                    .softmax();

    auto network = new NeuralNetwork([layers, layers.crossEntropy(dataSource(labels))]);

    auto updater = sgd(network.loss, network.parameters);

    import std.range : zip;

    foreach(fs, ls; zip(data.trainFeatures.chunks(100), data.trainLabels.chunks(100)))
    {
        auto loss = updater([
            features: Buffer(fs.joiner().array()),
            labels: Buffer(ls.joiner().array())
        ]);

        import std.stdio;

        writeln(loss);
    }
}
Authors:
  • Henry Gouk
Dependencies:
derelict-cuda, derelict-cudnn, cblas, derelict-nvrtc
Versions:
0.3.18 2018-Jul-31
0.3.17 2018-Jun-27
0.3.16 2018-Jun-07
0.3.15 2018-Jun-02
0.3.14 2018-Jun-02
Show all 23 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 0 downloads this month

  • 104 downloads total

Score:
1.5
Short URL:
dopt.dub.pm