dopt 0.2.0

A numerical optimisation framework

To use this package, put the following dependency into your project's dependencies section:



A numerical optimisation framework for the D programming language.

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)


Documentation can be found here.


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.


See examples/mnist.d for the full code.

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

        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])
                     .maxPool([2, 2])
                     .convolutional(32, [5, 5])
                     .maxPool([2, 2])

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

        auto updater = sgd(network.loss, cast(Operation[])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;

  • Henry Gouk
derelict-cuda, derelict-cudnn, cblas, derelict-nvrtc
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

  • 60 downloads total

Short URL: