EDDL is an open source library for numerical computation tailored to the healthcare domain.
More information: https://deephealth-project.eu/
- 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
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
orFPGA
} (uppercase)
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/.
To execute all unit tests, go to your build folder and run the following command:
make test
#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.
System | Compiler | Status |
---|---|---|
Windows (CPU) | VS 15.9.11 | |
Linux (CPU) | GCC 5.5.0 | |
Windows (GPU) | VS 15.9.11 | |
Linux (GPU) | GCC 5.5.0 |
Documentation available here.
If you are not a C++ fan, try PyEDDL, a python wrapper for this library.
- When I run an example from
examples/
I getsegmentation 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
orOPT=3
(uppercase). - GPU: Make sure you are using the computing service:
CS_GPU
.
- CPU: This is probably because your processor does not support
AVX instructions. Try to compile the source with the optimization flags: