Skip to content

European Distributed Deep Learning (EDDL) library. A general-purpose library initially developed to cover deep learning needs in healthcare use cases within the DeepHealth project.

License

Notifications You must be signed in to change notification settings

deephealthproject/eddl

Repository files navigation

EDDL


EDDL is an open source library for numerical computation tailored to the healthcare domain.

More information: https://deephealth-project.eu/

Requirements

  • CMake 3.9.2 or higher
  • A modern compiler with C++11 support

To clone all third_party submodules use:

git clone --recurse-submodules -j8 https://github.com/deephealthproject/eddl.git

Installation

To build eddl, clone or download this repository and then, from within the repository, run:

mkdir build
cd build
cmake ..
make

Compiler flags and options:

  • -DBUILD_PYTHON=ON: Compiles Python binding
  • -DBUILD_TESTS=ON: Compiles tests
  • -DBUILD_EXAMPLES=ON: Compiles examples
  • -DBUILD_TARGET=CPU: Compiles for {CPU, GPU or FPGA} (uppercase)

Windows specific installation

Default for Visual Studio 15 2017 build envrionment is x86, while EDDLL requires x64. This can be changed by typing cmake -A x64 . as cmake command.

On Windows, the POSIX threads library is required. Path to this library can be specified to cmake as follows: env PTHREADS_ROOT=path_to_pthreads cmake -A x64 . The PThreads library can be found at https://sourceforge.net/projects/pthreads4w/.

Tests

To execute all unit tests, go to your build folder and run the following command:

make test

Getting started

#include <stdio.h>
#include <stdlib.h>
#include <iostream>

#include "apis/eddl.h"
#include "apis/eddlT.h"

using namespace eddl;


int main(int argc, char **argv) {

    // Download dataset
    download_mnist();

    // Settings
    int epochs = 100;
    int batch_size = 100;
    int num_classes = 10;

    // Define network
    layer in = Input({784});
    layer l = in;  // Aux var

    l = BatchNormalization(Activation(L2(Dense(l, 1024),0.0001f), "relu"));
    l = BatchNormalization(Activation(L2(Dense(l, 1024),0.0001f), "relu"));
    l = BatchNormalization(Activation(L2(Dense(l, 1024),0.0001f), "relu"));

    layer out = Activation(Dense(l, num_classes), "softmax");
    model net = Model({in}, {out});

    plot(net, "model.pdf");

    // Build model
    build(net,
          sgd(0.01, 0.9), // Optimizer
          {"soft_cross_entropy"}, // Losses
          {"categorical_accuracy"}, // Metrics
          CS_CPU() // CPU with maximum threads availables
    );

    // View model
    cout<<summary(net);

    // Load dataset
    tensor x_train = eddlT::load("trX.bin");
    tensor y_train = eddlT::load("trY.bin");
    tensor x_test = eddlT::load("tsX.bin");
    tensor y_test = eddlT::load("tsY.bin");

    // Preprocessing
    eddlT::div_(x_train, 255.0);
    eddlT::div_(x_test, 255.0);


    // Train model
    for(int i=0;i<epochs;i++) {
      fit(net, {x_train}, {y_train}, batch_size, 1);

      // Evaluate test
      std::cout << "Evaluate test:\n";
      evaluate(net, {x_test}, {y_test});
    }
}

You can find more examples in the examples folder.

Continuous build status

System Compiler Status
Windows (CPU) VS 15.9.11 Build Status
Linux (CPU) GCC 5.5.0 Build Status
Windows (GPU) VS 15.9.11 Build Status
Linux (GPU) GCC 5.5.0 Build Status

Documentation available here.

Python wrapper

If you are not a C++ fan, try PyEDDL, a python wrapper for this library.

FAQs

  • When I run an example from examples/ I get segmentation fault (core dumped):
    • CPU: This is probably because your processor does not support AVX instructions. Try to compile the source with the optimization flags: OPT=2 or OPT=3 (uppercase).
    • GPU: Make sure you are using the computing service: CS_GPU.