Coder Social home page Coder Social logo

deephealthproject / eddl Goto Github PK

View Code? Open in Web Editor NEW
34.0 34.0 10.0 44.72 MB

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.

Home Page: https://deephealthproject.github.io/eddl/

License: MIT License

CMake 1.16% C++ 66.82% C 19.98% Cuda 6.19% Dockerfile 0.03% Shell 1.29% Ruby 0.03% Python 4.49%
autograd cpp deep-learning gpu machine-learning neural-network tensor

eddl's People

Contributors

adcastel avatar antodo avatar chavicoski avatar costantinograna avatar ilveroluca avatar izancatalan avatar jflich avatar jonandergomez avatar jorga20j avatar laumecha avatar lauracanalini avatar marioprojects avatar michelecancilla avatar prittt avatar rparedespalacios avatar salvacarrion avatar sanromra avatar seraphid avatar silviasdfg avatar simleo avatar stal12 avatar ynsehoornenborg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

eddl's Issues

CMake changes to build for GPU

Hi,

here is a changeset that enables building for GPU, originally proposed by @stal12 on Slack (python-apis channel):

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 44b1029..c905070 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -99,7 +99,7 @@ endif()
 
 # [MACRO] Download submodules
 macro(eddl_update_third_party SUBMODULE)
-    if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
+    if(GIT_FOUND AND IS_DIRECTORY "${PROJECT_SOURCE_DIR}/.git")
     # Update submodule as needed
         message(STATUS "${SUBMODULE} update")
         execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive third_party/${SUBMODULE}
@@ -272,6 +272,8 @@ endif(EDDL_SHARED)
 target_sources(eddl PRIVATE ${CPP_SOURCES})
 if(EDDL_WITH_CUDA AND CMAKE_CUDA_COMPILER)
     target_sources(eddl PRIVATE ${CUDA_SOURCES})
+    target_include_directories(eddl PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
+    add_compile_definitions(cGPU)
 endif()
 target_include_directories(eddl PUBLIC
        $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>

I've tested it with the following Dockerfile:

FROM stal12/cuda10-gcc5

COPY . /eddl
WORKDIR /eddl

RUN mkdir build && \
    cd build && \
    cmake -D BUILD_TARGET=gpu -D BUILD_TESTS=ON .. && \
    make -j$(grep -c ^processor /proc/cpuinfo)

RUN cd build && make install && \
    cp -rf install/include/eddl /usr/local/include/ && \
    cp -rf install/include/third_party/eigen/Eigen /usr/local/include/ && \
    cp install/lib/libeddl.a /usr/local/lib

I ran example_test on the resulting image and all seems OK:

Selecting GPU device 0
EDDLL is running on GPU device 0, GeForce GTX 1080 Ti
CuBlas initialized on GPU device 0, GeForce GTX 1080 Ti
CuRand initialized on GPU device 0, GeForce GTX 1080 Ti
====================
OK copy
====================
====================
OK set
====================
====================
OK mult2D
====================
====================
OK sum
====================

Note there is an extra line in the diff that changes GIT_FOUND AND EXISTS to GIT_FOUND AND IS_DIRECTORY. That's actually not related to GPU functionality: I added it because it allows building the Docker image even if eddl is a git submodule (as is the case in pyeddl).

Augment sphinx documentation using Breathe and Doxygen

Currently , we have a well-structured but simple documentation in sphinx so that users can know how to install and use the library (actually, just the EDDL API and Tensor object).

To improve it we have to include the Doxygen descriptions from the source code to the sphinx documentation with the help of a tool named Breathe.

Ps.:
There is already Doxygen documentation with all the parameters but it's "too ugly" and hard to read compared to the sphinx version:

Adapt testing to GPU

  • Check correctness against CPU (toy-examples)
  • Check speed-up against CPU using random large tensors (for small tensors, the CPU is usually more efficient)

Reduce memory consumption of "Select"

"tensor::select(A, B, descriptor)" uses a select descriptor, which contains an array for fast address translation A[i] = B[descriptor_address[i]].

Some layers use a select-like descriptor and therefore, they store all the precomputed addresses of a tensor when there is no need for that. Instead, we can precompute only the addresses for a single batch A[0, depth, height, width] and then replicate those addresses to the rest of the batches.

This would reduce the spatial cost in some layers from batches*depth*height*width to depth*height*width.

Layers that use tensor::select: Select, Permute, groupnorm and layernorm

eddlT::save fails if the path has no directory component

This worked in EDDL 0.2.2:

eddlT::save(t, "foo.bin", "bin");

But now it fails with:

The file could not be saved. Check if the directory exists or if you have permissions to write in it. (Tensor::save)

This is due to a problem with the newly introduced check for directory existence in Tensor::save, which does not handle the case of implicit CWD. Now the user is forced to do this in order to save to the CWD:

eddlT::save(t, "./foo.bin", "bin");

The mnist_[w]gan examples are currently broken due to this.

EDDL does not compile for GPU

As of 160c689 (current master branch as I'm writing this), the patch at #34 is not enough to build EDDL for GPU. I had to add missing sources to CMakeLists.txt and fix some problems in other files. This is the full patch I had to use:

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 200fc36..e2947d9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -99,7 +99,7 @@ endif()
 
 # [MACRO] Download submodules
 macro(eddl_update_third_party SUBMODULE)
-    if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
+    if(GIT_FOUND AND IS_DIRECTORY "${PROJECT_SOURCE_DIR}/.git")
     # Update submodule as needed
         message(STATUS "${SUBMODULE} update")
         execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive third_party/${SUBMODULE}
@@ -278,19 +278,27 @@ SET(CUDA_SOURCES
         src/hardware/gpu/gpu_hw.h
         src/hardware/gpu/gpu_comparison.cu
         src/hardware/gpu/gpu_core.cu
+        src/hardware/gpu/gpu_core_kernels.cu
         src/hardware/gpu/gpu_create.cu
+        src/hardware/gpu/gpu_create_kernels.cu
         src/hardware/gpu/gpu_generator.cu
         src/hardware/gpu/gpu_math.cu
+        src/hardware/gpu/gpu_math_kernels.cu
         src/hardware/gpu/gpu_reduction.cu
         src/hardware/gpu/gpu_tensor.cu
         src/hardware/gpu/gpu_tensor.h
         src/hardware/gpu/gpu_kernels.h
         src/hardware/gpu/nn/gpu_nn.h
         src/hardware/gpu/nn/gpu_activations.cu
+        src/hardware/gpu/nn/gpu_activations_kernels.cu
         src/hardware/gpu/nn/gpu_conv.cu
+        src/hardware/gpu/nn/gpu_conv_kernels.cu
         src/hardware/gpu/nn/gpu_losses.cu
+        src/hardware/gpu/nn/gpu_losses_kernels.cu
         src/hardware/gpu/nn/gpu_metrics.cu
+        src/hardware/gpu/nn/gpu_metrics_kernels.cu
         src/hardware/gpu/nn/gpu_pool.cu
+        src/hardware/gpu/nn/gpu_pool_kernels.cu
         )
 SET(SOURCES ${CPP_SOURCES} ${CUDA_SOURCES})
 
@@ -310,6 +318,8 @@ endif(EDDL_SHARED)
 target_sources(eddl PRIVATE ${CPP_SOURCES})
 if(EDDL_WITH_CUDA AND CMAKE_CUDA_COMPILER)
     target_sources(eddl PRIVATE ${CUDA_SOURCES})
+    target_include_directories(eddl PUBLIC ${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
+    add_compile_definitions(cGPU)
 endif()
 target_include_directories(eddl PUBLIC
 	$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
diff --git a/src/hardware/gpu/gpu_hw.h b/src/hardware/gpu/gpu_hw.h
index 3130eb4..42b69e3 100644
--- a/src/hardware/gpu/gpu_hw.h
+++ b/src/hardware/gpu/gpu_hw.h
@@ -43,7 +43,7 @@ void gpu_fill(Tensor *A, int aini, int aend, Tensor *B, int bini, int bend, int
 void gpu_select(Tensor *A, Tensor *B, vector<int> sind, int ini, int end);
 
 // GPU: Create (static)
-void gpu_range(Tensor *A, float min, float step, int size)
+void gpu_range(Tensor *A, float min, float step, int size);
 
 // GPU: Generator
 void gpu_rand_uniform(Tensor *A, float v);
diff --git a/src/hardware/gpu/gpu_kernels.h b/src/hardware/gpu/gpu_kernels.h
index cd7fb71..159fb7a 100644
--- a/src/hardware/gpu/gpu_kernels.h
+++ b/src/hardware/gpu/gpu_kernels.h
@@ -56,6 +56,7 @@ __global__ void mod_(float* a, long int rows, long int cols, float v);
 __global__ void mult_(float* a, long int rows, long int cols, float v);
 __global__ void normalize_(float* a, long int rows, long int cols, float min_ori, float max_ori, float min, float max);
 __global__ void pow_(float* a, long int rows, long int cols, float exp);
+__global__ void range(float* a, long int rows, long int cols, float min, float step, int size);
 __global__ void reciprocal_(float* a, long int rows, long int cols);
 __global__ void remainder_(float* a, long int rows, long int cols, float v);
 __global__ void round_(float* a, long int rows, long int cols);
diff --git a/src/tensor/tensor_create.cpp b/src/tensor/tensor_create.cpp
index 6ce948f..8733169 100644
--- a/src/tensor/tensor_create.cpp
+++ b/src/tensor/tensor_create.cpp
@@ -16,7 +16,7 @@ Tensor* raw_range(float min, float step, int size, int dev){
         cpu_range(t, min, step);
     }
 #ifdef cGPU
-    else if (isGPU())
+    else if (t->isGPU())
       {
         cpu_range(t, min, step);
       }

Could you please integrate these changes so it works out of the box?

Add GTest (again)

The pipeline is already setup. Moreover, there are enough tests to push it to the CI pipeline. The problem is that we need to rewrite a few tests so that they can be properly integrated into the CI setup using gTests and GitHub Actions.

Output of predict function

We are trying to train a simple net on MNIST and visualize the output predictions taking inspiration from the example_predict.
We add an iteration over the x_test tensor in order to take one sample per time and pass it to the predict function. After 10 epochs of training we have 0.997 of categorical accuracy according to the evaluate function, but all the predictions have very similar results.
So inside EDDL we print the target and the output of evaluate and the output of the predict function on two files. Values from evaluate are correct, values from predict seem to be wrong (see attached files).
Are we missing something?
output_evaluate.txt
output_predict.txt

#include <iostream>
#include <fstream>
#include <eddl/apis/eddl.h>

int main()
{
    download_mnist();

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

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

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

    // View model
    summary(net);
    plot(net, "model.pdf");

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

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

    // Preprocessing
    div(x_train, 255.0);
    div(x_test, 255.0);

    // Train model
    fit(net, { x_train }, { y_train }, batch_size, epochs);

    save(net, "model_mnist.bin");

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

    for (int j = 0; j < x_test->data->shape[0]; j++)
    {
        float max = 0.;
        int classe = -1;
        float *Y = (float*)malloc(1 * num_classes * sizeof(float));
        tensor TY = T({ 1,num_classes }, Y);
        auto *X = new float[1 * 784];
        tensor TX = T({ 1,784 }, X);

        memcpy(TX->data->ptr, x_test->data->ptr + TX->data->size * j, TX->data->size * sizeof(float));

        div(TX, 255.0);
        predict(net, { TX }, { TY });
        float *result = T_getptr(TY);

        for (int i = 0; i < num_classes; i++)
        {
            if (result[i] > max)
            {
                max = result[i];
                classe = i;
            }
        }
    }

    return 0;
}

Get Loss and Metric values inside the program rather than print them on screen

Good Morning,
following issue #108 I was trying to implement Early Stopping myself. I, however, run into a problem when trying to get the loss of my network in order to treat it the program rather than printing it on to the screen. This code does not work:

Loss* l = eddl::getLoss("soft_cross_entropy");
std::cout << eddl::compute_loss(l);

and fails with compilation error: cannot convert 'Loss*' to 'eddl::loss {aka NetLoss*}' for agument '1' to 'float eddl::compute_loss(eddl::loss)'
My question would hence be if you could please provide an exemple of how to use the provided functions to obtain the losses and metric values that are printed on the screen for each batch and epoch inside of the program.
Thank you in advance for your help.

Binary Crossentropy Loss function and Binary Accuracy Metric missing

Good Afternoon,
I looked at the documentation and at the list of Deep Learning features and I did not find the binary_crossentropy loss function as well as the binary_accuracy metric.
I was hence wondering wether you planned on releasing it in a nearby future nonetheless and, if not, how could I implement them with the current status of eddl.
Thank you in advance for your help

Installation in "standard" system directories

Currently, after EDDL is installed with CMake, e.g.:

mkdir build
cd build
cmake ..
make
make install

resulting artifacts (includes, libs and CMake output files) are all placed under the build/install dir. It would be useful to have an option to install these artifacts in "standard" system directories, such as /usr/lib and /usr/include. This would make pyeddl installation easier, since includes and libraries would be automatically found on the system.

I am not a CMake expert, but I think that CMake output files (e.g., EDDLConfig.cmake) should also be installed in some "standard" location so they can be found by other projects that use CMake's find_package (for instance, ECVL needs to find EDDL when compiled with EDDL support).

Possible bug in onnx import

Hello,

We try to import our onnx file with your example "3_onnx_import_net_from_file.cpp", nevertheless we have this error during import :

Producer_name: keras2onnx
Producer_version: 1.5.2
Domain: onnx
Model_version: 0
Input up_sampling2d_4_2/transpose_1:0 Is not avaliable
node->op_type Concat is not avaliable
Input up_sampling2d_3_2/transpose_1:0 Is not avaliable
node->op_type Concat is not avaliable
Input up_sampling2d_2_2/transpose_1:0 Is not avaliable
node->op_type Concat is not avaliable
Input up_sampling2d_1_2/transpose_1:0 Is not avaliable
node->op_type Concat is not avaliable

We test :
-> transpose network from keras to EDDL : OK
-> import onnx file with other framework : OK

Input onnx file :
onnx_test.zip

Best

Cannot build shared library

Shared library build (i.e., with -D EDDL_SHARED=ON passed to cmake) fails with:

[...]
[ 73%] Linking CXX shared library libeddl.so
CMakeFiles/eddl.dir/src/helpers.cpp.o: In function `get_next_row(std::istream&, CSVRow&, char const&)':
helpers.cpp:(.text+0x0): multiple definition of `get_next_row(std::istream&, CSVRow&, char const&)'
CMakeFiles/eddl.dir/src/tensor/tensor_serialization.cpp.o:tensor_serialization.cpp:(.text+0x3eba0): first defined here
collect2: error: ld returned 1 exit status
CMakeFiles/eddl.dir/build.make:2351: recipe for target 'libeddl.so' failed
make[2]: *** [libeddl.so] Error 1
CMakeFiles/Makefile2:442: recipe for target 'CMakeFiles/eddl.dir/all' failed
make[1]: *** [CMakeFiles/eddl.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

The problem seems to be that helpers.h contains the full definition (rather than just the declaration) of get_next_row. In this case include guards do not help, and the file is included by two different .cpp files. I was able to build the shared library by simply adding static to the definition:

diff --git a/src/helpers.h b/src/helpers.h
index e3b983f..6f37f6d 100644
--- a/src/helpers.h
+++ b/src/helpers.h
@@ -45,7 +45,7 @@ private:
     std::vector<std::string>    m_data;
 };
 
-std::istream& get_next_row(std::istream& str, CSVRow& data, const char &delimiter)
+static std::istream& get_next_row(std::istream& str, CSVRow& data, const char &delimiter)
 {
     data.readNextRow(str, delimiter);
     return str;

This could be a viable solution if get_next_row is meant to be used only by CSVIterator.

NOTE: this affects EDDL 0.3.

EarlyStopping Missing

Good Afternoon,
I looked at the documentation and at the list of Deep Learning features and I did not find any callback of the fit function. I was, more specifically, looking to the EarlyStopping callback.
I was hence wondering wether you planned on releasing it in a nearby future nonetheless and, if not, how could I implement them with the current status of eddl.
Thank you in advance for your help.

Bindings: expose tensor as buffer object

Hi,

this would have been clearer with a pull request, but it seems I don't have the right to either fork the repo or push a new branch.

We've started to look at the Python bindings. I've been working with Pybind11's support for exposing an object as a buffer on the Tensor class. Here is what I added to the binding code:

diff --git a/src/binding.cpp b/src/binding.cpp
index d513e6a..d8b81cc 100644
--- a/src/binding.cpp
+++ b/src/binding.cpp
@@ -54,7 +54,23 @@ PYBIND11_MODULE(_C, m) {
         .def_readonly("device", &Tensor::device)
         .def_readonly("ndim", &Tensor::ndim)
         .def_readonly("size", &Tensor::size)
-        .def_readonly("shape", &Tensor::shape);
+        .def_readonly("shape", &Tensor::shape)
+        .def_buffer([](Tensor &t) -> py::buffer_info {
+	  std::vector<ssize_t> strides(t.ndim);
+	  ssize_t S = sizeof(float);
+	  for (int i = t.ndim - 1; i >=0; --i) {
+	    strides[i] = S;
+	    S *= t.shape[i];
+	  }
+	  return py::buffer_info(
+            t.ptr,
+            sizeof(float),
+            py::format_descriptor<float>::format(),
+            t.ndim,
+            t.shape,
+	    strides
+	  );
+	});
     m.def("tensor_from_npy", &tensor_from_npy);
     m.def("tensor_getdata", &tensor_getdata);

Suppose you start with:

>>> import numpy as np
>>> import _C
>>> a = np.arange(12).reshape(3, 4).astype(np.float32)
>>> a
array([[ 0.,  1.,  2.,  3.],
       [ 4.,  5.,  6.,  7.],
       [ 8.,  9., 10., 11.]], dtype=float32)
>>> t = _C.tensor_from_npy(a, _C.DEV_CPU)

If you also have the buffer support as shown in the above diff, you can create an array that uses the same memory area as the tensor and do things like combining tensors and numpy arrays with operators:

>>> b = np.array(t, copy=False)
>>> b
array([[ 0.,  1.,  2.,  3.],
       [ 4.,  5.,  6.,  7.],
       [ 8.,  9., 10., 11.]], dtype=float32)
>>> b *= 2
>>> _C.tensor_getdata(t)
array([[ 0.,  2.,  4.,  6.],
       [ 8., 10., 12., 14.],
       [16., 18., 20., 22.]], dtype=float32)
>>> b + t
array([[ 0.,  4.,  8., 12.],
       [16., 20., 24., 28.],
       [32., 36., 40., 44.]], dtype=float32)

Let me know what you think.

Review minimum version requirements

Ubuntu ships with cmake 3.10.2 but there are cmake functions that require a higher version such as: add_compile_definitions.

The idea is to use the older cmake version possible that supports all our needs or lower our requirements to ease the installation process.

Access to the computational graph

How should different parts of the computational graph be accessed given an arbitrary sized input tensor? Is there an interface to do that? After inspecting the code we encounter two things we are not able to do with the provided interface:

  • we are not able to copy an arbitrary sized input tensor into the input layer. This requires the rebuild of the graph input shape.

  • we are not able to copy the EDDL output into a float*. Nor even copying it to a Tensor class solves the problem. After code inspection (EDDL.evaluate function) it seems that several different operations are performed to achieve this goal.

The pseudocode we are looking for is the following:

// network
layer in = eddl.Input({ batch,3,28,28 });
layer l = in;

l = eddl.MaxPool(eddl.Activation(eddl.Conv(l, 16, { 3,3 }), "relu"), { 2,2 });
l = eddl.MaxPool(eddl.Activation(eddl.Conv(l, 32, { 3,3 }), "relu"), { 2,2 });
l = eddl.MaxPool(eddl.Activation(eddl.Conv(l, 64, { 3,3 }), "relu"), { 2,2 });
l = eddl.MaxPool(eddl.Activation(eddl.Conv(l, 128, { 3,3 }), "relu"), { 2,2 });

l = eddl.Reshape(l, { batch,-1 });
l = eddl.Activation(eddl.Dense(l, 32), "relu");

layer out = eddl.Activation(eddl.Dense(l, 10), "softmax");
// net define input and output layers list
model net = eddl.Model({ in }, { out });

// sequences of instructions
float* X = // allocate memory properly for input image
float* Y= // allocate memory properly for the desired output of the graph
X=Load_image_into_float32(‘path_to_file’);
in.copy_my_data_into_the_graph(X)
net->forward();
EDDL.copy_back_to_float(out.output, Y); // output attribute stores the value of the output layer

From-vector constructors to support Python bindings

Methods that take initializer_list as argument cannot be bound in Python. In order to support the Python bindings, objects with methods that take initializer lists should also provide a version that takes vectors instead. For instance, we had to add a new constructor to CompServ in order to bind it:

--- a/src/compserv.h
+++ b/src/compserv.h
@@ -40,6 +40,8 @@ public:
     // for local
     CompServ(int threads, const initializer_list<int> &g, const initializer_list<int> &f);
 
+    CompServ(int threads, vector<int> g, vector<int> f);
+
     // for Distributed
     explicit CompServ(FILE *csspec);

Possible problem with Transpose

This program:

#include <eddl/apis/eddl.h>

using namespace eddl;

int main(int argc, char **argv) {
    layer in = Input({3, 16, 16});
    layer t = Transpose(in);
}

Gives the following error:

terminate called after throwing an instance of 'std::runtime_error'
  what():  Dimensions do not match (utils::permute_indices)
Aborted (core dumped)

Am I calling Transpose with the wrong input or is there a problem in Transpose?

"double free or corruption" error

I tried to build the Python bindings against the current eddl develop branch and found out that network training examples crashed at the end with a "double free or corruption" error (and subsequent core dump). This is likely connected to the recent adding of a destructor for layers, since the Python interpreter, before exiting, tries to delete everything, and this results in a call of each layer's destructor. After instrumenting the eddl code with a series of prints, I managed to pinpoint the error using the MLP example as the driver:

Destroying Layer: 'activation4'
  delete input
    destroying Tensor
      delete tsem
  delete output
    destroying Tensor
      delete tsem
  delete delta
    destroying Tensor
      delete tsem
  delete target
    destroying Tensor
      delete tsem
Done: 'activation4'
Destroying Layer: 'dense4'
  delete input
    destroying Tensor
      delete tsem
  delete output
    destroying Tensor
      delete tsem
  delete delta
    destroying Tensor
      delete tsem
  delete target
Done: 'dense4'
Destroying Layer: 'activation3'
  delete input
    destroying Tensor
      delete tsem
  delete output
    destroying Tensor
      delete tsem
  delete delta
    destroying Tensor
      delete tsem
  delete target
Done: 'activation3'
Destroying Layer: 'dense3'
  delete input
    destroying Tensor
      delete tsem
  delete output
    destroying Tensor
double free or corruption (!prev)
Aborted (core dumped)

The program crashes in the Tensor destructor, while trying to delete the data pointer (note it does not get to the "delete tsem" phase).

To exclude the possibility that this problem was due to something on the Python side, I reproduced the problem with a C++ program:

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

#include <eddl/apis/eddl.h>

using namespace eddl;


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

    int epochs = 1;
    int batch_size = 1000;
    int num_classes = 10;

    layer in = Input({784});
    layer d1 = Dense(in, 1024);
    layer a1 = Activation(d1, "relu");
    layer d2 = Dense(a1, 1024);
    layer a2 = Activation(d2, "relu");
    layer d3 = Dense(a2, 1024);
    layer a3 = Activation(d3, "relu");
    layer d4 = Dense(a3, num_classes);
    layer out = Activation(d4, "softmax");
    model net = Model({in}, {out});

    build(net,
          sgd(0.01, 0.9),
          {"soft_cross_entropy"},
          {"categorical_accuracy"},
          CS_CPU(4)
    );

    cout << summary(net);

    tensor x_train = T_load("trX.bin");
    tensor y_train = T_load("trY.bin");
    tensor x_test = T_load("tsX.bin");
    tensor y_test = T_load("tsY.bin");

    div(x_train, 255.0);
    div(x_test, 255.0);

    fit(net, {x_train}, {y_train}, batch_size, epochs);
    evaluate(net, {x_test}, {y_test});

    delete out;
    delete d4;
    delete a3;
    delete d3;
    delete a2;
    delete d2;
    delete a1;
    delete d1;
    delete in;
}

which leads to exactly the same output and error as above.

For completeness, the exact eddl commit I have used is 46305c2, and the code instrumentation was:

diff --git a/src/layers/core/layer_tensor.cpp b/src/layers/core/layer_tensor.cpp
index e27f3fd..559b0d5 100644
--- a/src/layers/core/layer_tensor.cpp
+++ b/src/layers/core/layer_tensor.cpp
@@ -90,9 +90,14 @@ void LTensor::resize(int batch){
 
 LTensor::~LTensor()
 {
+  cout << "Destroying LTensor: '" << this->name << "'\n";
+  cout << "  delete input\n";
   delete input;
+  cout << "  delete delta\n";
   delete delta;
+  cout << "  setting pointers to null\n";
   delta = input = output = nullptr;
+  cout << "Done: '" << this->name << "'\n";
 }
 
 /// OP OVERLOAD
diff --git a/src/layers/layer.cpp b/src/layers/layer.cpp
index d322177..73ae1b4 100644
--- a/src/layers/layer.cpp
+++ b/src/layers/layer.cpp
@@ -34,11 +34,16 @@ Layer::Layer(string name, int dev) {
 
 Layer::~Layer()
 {
+  cout << "Destroying Layer: '" << this->name << "'\n";
+  cout << "  delete input\n";
   if (input!=nullptr) delete input;
+  cout << "  delete output\n";
   if (output!=nullptr) delete output;
+  cout << "  delete delta\n";
   if (delta!=nullptr) delete delta;
+  cout << "  delete target\n";
   if (target!=nullptr) delete target;
-
+  cout << "Done: '" << this->name << "'\n";
 }
 
 void Layer::initialize() {
diff --git a/src/tensor/tensor.cpp b/src/tensor/tensor.cpp
index 7dfabc2..65bbe5d 100755
--- a/src/tensor/tensor.cpp
+++ b/src/tensor/tensor.cpp
@@ -223,6 +223,7 @@ void Tensor::resize(int b, Tensor *T)
 
 
 Tensor::~Tensor() {
+    cout << "    destroying Tensor\n";
     if (isCPU()) {
         delete ptr;
     }
@@ -237,6 +238,7 @@ Tensor::~Tensor() {
       // delete FPGA Tensor
     }
 #endif
+    cout << "      delete tsem\n";
     delete tsem;
 }

Conv test example

Hi, we tried your test_eddl_conv example to understand how to manage Tensors.
With the example network everything works well, but if we change its architecture, for example changing the output dimension of the first Conv layer from 16 to 64 or removing the first MaxPool layer, the program crashes in the building of the network for a bad allocation exception.
Are we using the example code in a wrong way?

https://github.com/deephealthproject/EDDLL/blob/8073583d2d6f6fa421f3c26bf6232c5c2e1b14be/examples/MNIST/test_eddl_conv.cpp#L65-L69

Cannot compile due to Eigen

Workaround: This is not common. Nevertheless, you can avoid this issue by using a conda environment.

In some systems, I get this error when compiling the EDDL:

In file included from /usr/include/eigen3/Eigen/Dense:1:0,
                 from /home/.../eddl/src/hardware/gpu/../../tensor/tensor.h:20,
                 from /home/.../eddl/src/hardware/gpu/gpu_hw.h:19,
                 from /home/.../eddl/src/hardware/gpu/gpu_da.cu:17:
/usr/include/eigen3/Eigen/Core:42:14: fatal error: math_functions.hpp: No such file or directory
     #include <math_functions.hpp>

Here, Eigen has been installed from source (stable 3.3.7) and also, through sudo apt install libeigen3-dev

Failure to build on Windows

When I tried to build the EDDL on my Windows machine. I got some errors from CMake.

I’m running Windows 10 X64, using Visual Studio 15 2017 Win64.

Console output:
PS D:\views\DeepHealth\EDDLL\src> cmake .
CMake Error at CMakeLists.txt:1 (target_sources):
Cannot specify sources for target "EDDLL" which is not built by this
project.

CMake Error at layers/CMakeLists.txt:1 (target_sources):
Cannot specify sources for target "EDDLL" which is not built by this
project.

CMake Error at CMakeLists.txt:12 (add_subdirectory):
add_subdirectory given source "cpu" which is not an existing directory.

CMake Error at CMakeLists.txt:14 (target_include_directories):
Cannot specify include directories for target "EDDLL" which is not built by
this project.

CMake Error at CMakeLists.txt:15 (target_include_directories):
Cannot specify include directories for target "EDDLL" which is not built by
this project.

CMake Warning (dev) in CMakeLists.txt:
No cmake_minimum_required command is present. A line of code such as

cmake_minimum_required(VERSION 3.12)

should be added at the top of the file. The version specified may be lower
if you wish to support older CMake versions for this project. For more
information run "cmake --help-policy CMP0000".
This warning is for project developers. Use -Wno-dev to suppress it.

-- Configuring incomplete, errors occurred!
See also "D:/views/DeepHealth/EDDLL/src/CMakeFiles/CMakeOutput.log".
PS D:\views\DeepHealth\EDDLL\src> cmake --version
cmake version 3.12.4

segfault while running example_conv

I got a segfault while trying to run example_conv (Linux on Docker, using https://github.com/deephealthproject/pyeddl/blob/binder_example/Dockerfile):

Generating Random Table
sh: 1: dot: not found
input1 reshape1 conv1 activation1 pool1 conv2 activation2 pool2 conv3 activation3 pool3 conv4 activation4 pool4 reshape2 dense1 activation5 dense2 activation6 
input1: (1x784)-->(1x784)
reshape1: (1x784)-->(1x1x28x28)
conv1: (1x1x28x28)-->(1x16x28x28)
activation1: (1x16x28x28)-->(1x16x28x28)
pool1: (1x16x28x28)-->(1x16x14x14)
conv2: (1x16x14x14)-->(1x32x14x14)
activation2: (1x32x14x14)-->(1x32x14x14)
pool2: (1x32x14x14)-->(1x32x7x7)
conv3: (1x32x7x7)-->(1x64x7x7)
activation3: (1x64x7x7)-->(1x64x7x7)
pool3: (1x64x7x7)-->(1x64x3x3)
conv4: (1x64x3x3)-->(1x128x3x3)
activation4: (1x128x3x3)-->(1x128x3x3)
pool4: (1x128x3x3)-->(1x128x1x1)
reshape2: (1x128x1x1)-->(1x128)
dense1: (1x128)-->(1x32)
activation5: (1x32)-->(1x32)
dense2: (1x32)-->(1x10)
activation6: (1x10)-->(1x10)

Build net
Net running on CPU
set threads to 4
Split 0
Build net
Net running on CPU
Split 1
Build net
Net running on CPU
Split 2
Build net
Net running on CPU
Split 3
Build net
Net running on CPU
loading file with tensor:(60000x784)
loading file with tensor:(60000x10)
5 epochs of 60 batches of size 1000
Epoch 1
Segmentation fault (core dumped)

Avoid Conda conflict with gcc omp in some machines

In some machines, we have identified problems to use the EDDL correctly due to a conflict between conda and gcc. We need to either resolve the issue or find a workaround for the user.

Cannot generate a safe runtime search path for target first_example because
 files in some directories may conflict with libraries in implicit
 directories:

   runtime library [libgomp.so.1] in /usr/lib/gcc/x86_64-linux-gnu/5 may be hidden by files in:
     /home/{user}/anaconda3/lib

 Some of these libraries may not be found correctly.

Windows: 'pthread.h': No such file or directory

Since the native Windows threading API is exposed via #include <windows.h>, we need to make some minor changes to support the EDDL on Windows. We should modify: CMakeLists.txt, eddlConfig.cmake.in and some functions inside the folder net/ (...although I might be missing something else, check it)

I'll leave this issue for the Windows fans 😉

To build it type this from the source directory:

mkdir build; cd build
cmake -G "NMake Makefiles" ..
nmake
nmake install

Segfault deleting net with no call to build

This program produces a segmentation fault:

#include <eddl/apis/eddl.h>

using namespace eddl;

int main(int argc, char **argv) {
    layer in = Input({784});
    layer l = in;
    l = Activation(Dense(l, 256), "relu");
    layer out = Dense(l, 784);
    model net = Model({in}, {out});
    delete net;
}

The problem seems to be that the Net destructor assumes the presence of some attributes that are only created after a call to build (i.e., the constructor does not fully construct the object).

In Python the problem occurs even without the explicit deletion of net, since it's destroyed automatically when the interpreter exits.

Automatic header recognition for CSV/TSV/TXT

Currently, we can open text delimited files (CSV/TSV/TXT) with and without headers using these function: Tensor::load_from_txt("iris.txt", ',', lines_to_ignore);. The problem is that we need to specify the number of initial lines to be ignored.

We also have this function Tensor::load(filename) that can open those files automatically, but it assumes that there are no headers.

Therefore, we have to implement a small piece of code to detect the number of headers in a text delimited file.

Add extra modes to the data augmentation functions

Some tensor transformations, such as shift, rotate, scale,... have a mode parameter. This parameter is used to specify how that transformation is going to be performed.

For shift-like operations, we have to implement the following policies:

  • constant: DONE
  • nearest
  • reflect
  • wrap

For scale-like operations, we have to implement the following policies:

  • Nearest neighbor: DONE
  • Bi-linear
  • Bi-cubic

For rotation-like operations*, we have to implement the following policies:

  • original: DONE
  • constant: DONE

*The rotation algorithm should be also improved (we currently use a sort of nearest neighbor rotation effect, "too sharp")

Update Jenkins

For the CI/CD we are using Github actions. The problem is that GitHub does not currently support GPU building/testing so we want to update our Jenkins file in order to test it on GPU for Linux and Windows.

Compilation fails with CMake version 3.14.0 and g++ version 4.8.5

Good Morning,
I am experiencing issues compiling eddl using CMake version 3.14.0 and g++ version 4.8.5 with the following CMake flags: -DBUILD_TARGET=CPU -DBUILD_SHARED_LIB=ON -DMKL=ON -DBUILD_PROTOBUF=OFF -DBUILD_OPENMP=ON -DBUILD_HPC=ON -DBUILD_TESTS=ON -DBUILD_EXAMPLES=ON -DCMAKE_INSTALL_PREFIX=/home/oliveri/oliveri/eddl on Linux CentOS.
However, everything works on my machine with CMake version 3.16.4 and g++ version 7.4.0 on Ubuntu.
Here is the output of CMake:

-- The CXX compiler identification is GNU 4.8.5
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenMP_CXX: -fopenmp (found version "3.1")
-- Found OpenMP: TRUE (found version "3.1")
-- Found OpenMP, version 3
-- Found ZLIB: /usr/lib64/libz.so (found version "1.2.7")
-- Looking for C++ include pthread.h
-- Looking for C++ include pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE
-- Install path: /home/oliveri/oliveri/eddl
-- ===========================================
-- ===========================================
-- Build type: Release
-- Build target: CPU
-- Build tests: ON
-- Build examples: ON
-- Build OpenMP: ON
-- Build Protobuf: OFF
-- Build HPC: ON
-- Use Intel-MKL: ON
-- C++ compiler: GNU
-- C++ flags:  -DEIGEN_FAST_MATH -pipe
-- C++ flags (release): -Ofast -march=native -fno-signed-zeros -fno-trapping-math -funroll-loops -frename-registers
-- C++ flags (debug): -g -Og
-- CUDA Enabled:
-- CUDA flags:
-- ===========================================
-- ===========================================
-- Configuring done
-- Generating done
-- Build files have been written to: /home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/build

and here is the output upon compilation with make:

Scanning dependencies of target eddl
[  0%] Building CXX object CMakeFiles/eddl.dir/src/random.cpp.o
[  1%] Building CXX object CMakeFiles/eddl.dir/src/utils.cpp.o
[  1%] Building CXX object CMakeFiles/eddl.dir/src/apis/eddl.cpp.o
[  2%] Building CXX object CMakeFiles/eddl.dir/src/descriptors/descriptor_conv.cpp.o
[  2%] Building CXX object CMakeFiles/eddl.dir/src/apis/eddlT.cpp.o
[  3%] Building CXX object CMakeFiles/eddl.dir/src/descriptors/descriptor_pool.cpp.o
[  4%] Building CXX object CMakeFiles/eddl.dir/src/descriptors/descriptor_permute.cpp.o
[  4%] Building CXX object CMakeFiles/eddl.dir/src/descriptors/descriptor_select.cpp.o
[  5%] Building CXX object CMakeFiles/eddl.dir/src/descriptors/descriptor_reduce.cpp.o
[  5%] Building CXX object CMakeFiles/eddl.dir/src/descriptors/descriptor_tensor.cpp.o
[  6%] Building CXX object CMakeFiles/eddl.dir/src/hardware/cpu/cpu_comparison.cpp.o
[  6%] Building CXX object CMakeFiles/eddl.dir/src/hardware/cpu/cpu_create.cpp.o
[  7%] Building CXX object CMakeFiles/eddl.dir/src/hardware/cpu/cpu_core.cpp.o
[  8%] Building CXX object CMakeFiles/eddl.dir/src/hardware/cpu/cpu_generator.cpp.o
[  8%] Building CXX object CMakeFiles/eddl.dir/src/hardware/cpu/cpu_da.cpp.o
[  8%] Building CXX object CMakeFiles/eddl.dir/src/hardware/cpu/cpu_math.cpp.o
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/random.cpp: In function ‘void build_randn_table()’:
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/random.cpp:55:58: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
         RTable = get_fmem(MAX_RTABLE, "build_randn_table");
                                                          ^
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/utils.cpp: In function ‘char* humanSize(uint64_t)’:
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/utils.cpp:97:50: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
     char *suffix[] = {"B", "KB", "MB", "GB", "TB"};
                                                  ^
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/utils.cpp:97:50: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/utils.cpp:97:50: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/utils.cpp:97:50: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/utils.cpp:97:50: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
[  8%] Building CXX object CMakeFiles/eddl.dir/src/hardware/cpu/cpu_reduction.cpp.o
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/descriptors/descriptor_conv.cpp: In member function ‘void ConvolDescriptor::build(Tensor*)’:
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/descriptors/descriptor_conv.cpp:108:83: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
         ptrI=get_fmem(A->shape[0] * r * c * kr * kc * kz,"ConvolDescriptor::build");
                                                                                   ^
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/descriptors/descriptor_conv.cpp: In member function ‘void ConvolDescriptor::resize(int)’:
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/descriptors/descriptor_conv.cpp:151:74: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
         ptrI=get_fmem(b * r * c * kr * kc * kz, "ConvolDescriptor::build");
                                                                          ^
[  9%] Building CXX object CMakeFiles/eddl.dir/src/hardware/cpu/nn/cpu_activations.cpp.o
[  9%] Building CXX object CMakeFiles/eddl.dir/src/hardware/cpu/nn/cpu_conv.cpp.o
[ 10%] Building CXX object CMakeFiles/eddl.dir/src/hardware/cpu/nn/cpu_losses.cpp.o
[ 11%] Building CXX object CMakeFiles/eddl.dir/src/hardware/cpu/nn/cpu_metrics.cpp.o
[ 11%] Building CXX object CMakeFiles/eddl.dir/src/hardware/cpu/nn/cpu_pool.cpp.o
[ 11%] Building CXX object CMakeFiles/eddl.dir/src/hardware/cpu/nn/cpu_tensor_nn.cpp.o
[ 12%] Building CXX object CMakeFiles/eddl.dir/src/initializers/initializer.cpp.o
[ 12%] Building CXX object CMakeFiles/eddl.dir/src/initializers/initializer_constant.cpp.o
[ 13%] Building CXX object CMakeFiles/eddl.dir/src/initializers/initializer_glorot_normal.cpp.o
[ 13%] Building CXX object CMakeFiles/eddl.dir/src/initializers/initializer_glorot_uniform.cpp.o
[ 14%] Building CXX object CMakeFiles/eddl.dir/src/initializers/initializer_indentity.cpp.o
[ 14%] Building CXX object CMakeFiles/eddl.dir/src/initializers/initializer_orthogonal.cpp.o
[ 15%] Building CXX object CMakeFiles/eddl.dir/src/initializers/initializer_random_normal.cpp.o
[ 15%] Building CXX object CMakeFiles/eddl.dir/src/initializers/initializer_random_uniform.cpp.o
[ 16%] Building CXX object CMakeFiles/eddl.dir/src/initializers/initializer_truncated_normal.cpp.o
[ 16%] Building CXX object CMakeFiles/eddl.dir/src/initializers/initializer_variance_scaling.cpp.o
[ 17%] Building CXX object CMakeFiles/eddl.dir/src/layers/constraints/constraint.cpp.o
[ 17%] Building CXX object CMakeFiles/eddl.dir/src/layers/constraints/constraint_max_norm.cpp.o
[ 18%] Building CXX object CMakeFiles/eddl.dir/src/layers/constraints/constraint_min_max_norm.cpp.o
[ 18%] Building CXX object CMakeFiles/eddl.dir/src/layers/constraints/constraint_non_neg.cpp.o
[ 19%] Building CXX object CMakeFiles/eddl.dir/src/layers/constraints/constraint_unit_norm.cpp.o
[ 19%] Building CXX object CMakeFiles/eddl.dir/src/layers/conv/layer_conv.cpp.o
[ 20%] Building CXX object CMakeFiles/eddl.dir/src/layers/conv/layer_transposed_conv.cpp.o
[ 20%] Building CXX object CMakeFiles/eddl.dir/src/layers/conv/layer_upsampling.cpp.o
[ 21%] Building CXX object CMakeFiles/eddl.dir/src/layers/core/layer_activation.cpp.o
[ 21%] Building CXX object CMakeFiles/eddl.dir/src/layers/core/layer_dense.cpp.o
[ 22%] Building CXX object CMakeFiles/eddl.dir/src/layers/core/layer_drop.cpp.o
[ 22%] Building CXX object CMakeFiles/eddl.dir/src/layers/core/layer_embedding.cpp.o
[ 23%] Building CXX object CMakeFiles/eddl.dir/src/layers/core/layer_input.cpp.o
[ 23%] Building CXX object CMakeFiles/eddl.dir/src/layers/core/layer_reshape.cpp.o
[ 24%] Building CXX object CMakeFiles/eddl.dir/src/layers/core/layer_tensor.cpp.o
[ 24%] Building CXX object CMakeFiles/eddl.dir/src/layers/core/layer_transpose.cpp.o
[ 25%] Building CXX object CMakeFiles/eddl.dir/src/layers/da/layer_crop.cpp.o
[ 25%] Building CXX object CMakeFiles/eddl.dir/src/layers/da/layer_crop_random.cpp.o
[ 26%] Building CXX object CMakeFiles/eddl.dir/src/layers/da/layer_crop_scale.cpp.o
[ 26%] Building CXX object CMakeFiles/eddl.dir/src/layers/da/layer_crop_scale_random.cpp.o
[ 27%] Building CXX object CMakeFiles/eddl.dir/src/layers/da/layer_cutout.cpp.o
[ 27%] Building CXX object CMakeFiles/eddl.dir/src/layers/da/layer_cutout_random.cpp.o
[ 28%] Building CXX object CMakeFiles/eddl.dir/src/layers/da/layer_da.cpp.o
[ 28%] Building CXX object CMakeFiles/eddl.dir/src/layers/da/layer_flip.cpp.o
[ 29%] Building CXX object CMakeFiles/eddl.dir/src/layers/da/layer_flip_random.cpp.o
[ 29%] Building CXX object CMakeFiles/eddl.dir/src/layers/da/layer_rotate.cpp.o
[ 30%] Building CXX object CMakeFiles/eddl.dir/src/layers/da/layer_rotate_random.cpp.o
[ 30%] Building CXX object CMakeFiles/eddl.dir/src/layers/da/layer_scale.cpp.o
[ 31%] Building CXX object CMakeFiles/eddl.dir/src/layers/da/layer_scale_random.cpp.o
[ 31%] Building CXX object CMakeFiles/eddl.dir/src/layers/da/layer_shift.cpp.o
[ 32%] Building CXX object CMakeFiles/eddl.dir/src/layers/da/layer_shift_random.cpp.o
[ 32%] Building CXX object CMakeFiles/eddl.dir/src/layers/generators/layer_gauss.cpp.o
[ 33%] Building CXX object CMakeFiles/eddl.dir/src/layers/generators/layer_generator.cpp.o
[ 33%] Building CXX object CMakeFiles/eddl.dir/src/layers/generators/layer_uniform.cpp.o
[ 34%] Building CXX object CMakeFiles/eddl.dir/src/layers/layer.cpp.o
[ 34%] Building CXX object CMakeFiles/eddl.dir/src/layers/merge/layer_add.cpp.o
[ 35%] Building CXX object CMakeFiles/eddl.dir/src/layers/merge/layer_average.cpp.o
[ 35%] Building CXX object CMakeFiles/eddl.dir/src/layers/merge/layer_concat.cpp.o
[ 36%] Building CXX object CMakeFiles/eddl.dir/src/layers/merge/layer_matmul.cpp.o
[ 36%] Building CXX object CMakeFiles/eddl.dir/src/layers/merge/layer_maximum.cpp.o
[ 37%] Building CXX object CMakeFiles/eddl.dir/src/layers/merge/layer_minimum.cpp.o
[ 37%] Building CXX object CMakeFiles/eddl.dir/src/layers/merge/layer_subtract.cpp.o
[ 38%] Building CXX object CMakeFiles/eddl.dir/src/layers/noise/layer_gaussian.cpp.o
[ 38%] Building CXX object CMakeFiles/eddl.dir/src/layers/normalization/bnorm.cpp.o
[ 39%] Building CXX object CMakeFiles/eddl.dir/src/layers/normalization/layer_batchnorm.cpp.o
[ 39%] Building CXX object CMakeFiles/eddl.dir/src/layers/normalization/layer_groupnorm.cpp.o
[ 40%] Building CXX object CMakeFiles/eddl.dir/src/layers/normalization/layer_layernorm.cpp.o
[ 41%] Building CXX object CMakeFiles/eddl.dir/src/layers/normalization/layer_norm.cpp.o
[ 41%] Building CXX object CMakeFiles/eddl.dir/src/layers/normalization/layer_normmax.cpp.o
[ 42%] Building CXX object CMakeFiles/eddl.dir/src/layers/normalization/layer_normminmax.cpp.o
[ 42%] Building CXX object CMakeFiles/eddl.dir/src/layers/operators/layer_abs.cpp.o
[ 43%] Building CXX object CMakeFiles/eddl.dir/src/layers/operators/layer_diff.cpp.o
[ 43%] Building CXX object CMakeFiles/eddl.dir/src/layers/operators/layer_div.cpp.o
[ 44%] Building CXX object CMakeFiles/eddl.dir/src/layers/operators/layer_exp.cpp.o
[ 44%] Building CXX object CMakeFiles/eddl.dir/src/layers/operators/layer_log.cpp.o
[ 45%] Building CXX object CMakeFiles/eddl.dir/src/layers/operators/layer_log10.cpp.o
[ 45%] Building CXX object CMakeFiles/eddl.dir/src/layers/operators/layer_log2.cpp.o
[ 46%] Building CXX object CMakeFiles/eddl.dir/src/layers/operators/layer_mult.cpp.o
[ 46%] Building CXX object CMakeFiles/eddl.dir/src/layers/operators/layer_operator.cpp.o
[ 47%] Building CXX object CMakeFiles/eddl.dir/src/layers/operators/layer_permute.cpp.o
[ 47%] Building CXX object CMakeFiles/eddl.dir/src/layers/operators/layer_pow.cpp.o
[ 48%] Building CXX object CMakeFiles/eddl.dir/src/layers/operators/layer_select.cpp.o
[ 48%] Building CXX object CMakeFiles/eddl.dir/src/layers/operators/layer_sqrt.cpp.o
[ 49%] Building CXX object CMakeFiles/eddl.dir/src/layers/operators/layer_sum.cpp.o
[ 49%] Building CXX object CMakeFiles/eddl.dir/src/layers/pool/layer_avgpool.cpp.o
[ 50%] Building CXX object CMakeFiles/eddl.dir/src/layers/pool/layer_maxpool.cpp.o
[ 50%] Building CXX object CMakeFiles/eddl.dir/src/layers/pool/layer_pool.cpp.o
[ 51%] Building CXX object CMakeFiles/eddl.dir/src/layers/recurrent/layer_lstm.cpp.o
[ 51%] Building CXX object CMakeFiles/eddl.dir/src/layers/recurrent/layer_rnn.cpp.o
[ 52%] Building CXX object CMakeFiles/eddl.dir/src/layers/reductions/layer_max.cpp.o
[ 52%] Building CXX object CMakeFiles/eddl.dir/src/layers/reductions/layer_mean.cpp.o
[ 53%] Building CXX object CMakeFiles/eddl.dir/src/layers/reductions/layer_min.cpp.o
[ 53%] Building CXX object CMakeFiles/eddl.dir/src/layers/reductions/layer_reduction.cpp.o
[ 54%] Building CXX object CMakeFiles/eddl.dir/src/layers/reductions/layer_var.cpp.o
[ 54%] Building CXX object CMakeFiles/eddl.dir/src/layers/reductions/layer_sum.cpp.o
[ 55%] Building CXX object CMakeFiles/eddl.dir/src/losses/loss.cpp.o
[ 55%] Building CXX object CMakeFiles/eddl.dir/src/losses/loss_cross_entropy.cpp.o
[ 56%] Building CXX object CMakeFiles/eddl.dir/src/losses/loss_hinge.cpp.o
[ 56%] Building CXX object CMakeFiles/eddl.dir/src/losses/loss_mae.cpp.o
[ 57%] Building CXX object CMakeFiles/eddl.dir/src/losses/loss_min.cpp.o
[ 57%] Building CXX object CMakeFiles/eddl.dir/src/losses/loss_mre.cpp.o
[ 58%] Building CXX object CMakeFiles/eddl.dir/src/losses/loss_mse.cpp.o
[ 58%] Building CXX object CMakeFiles/eddl.dir/src/losses/loss_msle.cpp.o
[ 59%] Building CXX object CMakeFiles/eddl.dir/src/losses/loss_soft_cross_entropy.cpp.o
[ 59%] Building CXX object CMakeFiles/eddl.dir/src/metrics/metric.cpp.o
[ 60%] Building CXX object CMakeFiles/eddl.dir/src/metrics/metric_categorical_acc.cpp.o
[ 60%] Building CXX object CMakeFiles/eddl.dir/src/metrics/metric_mean_absolute_error.cpp.o
[ 61%] Building CXX object CMakeFiles/eddl.dir/src/metrics/metric_mean_relative_error.cpp.o
[ 61%] Building CXX object CMakeFiles/eddl.dir/src/metrics/metric_mean_squared_error.cpp.o
[ 62%] Building CXX object CMakeFiles/eddl.dir/src/metrics/metric_sum.cpp.o
[ 62%] Building CXX object CMakeFiles/eddl.dir/src/net/compserv.cpp.o
[ 63%] Building CXX object CMakeFiles/eddl.dir/src/net/net.cpp.o
[ 63%] Building CXX object CMakeFiles/eddl.dir/src/net/net_api.cpp.o
[ 64%] Building CXX object CMakeFiles/eddl.dir/src/net/net_build.cpp.o
[ 64%] Building CXX object CMakeFiles/eddl.dir/src/net/net_func.cpp.o
[ 65%] Building CXX object CMakeFiles/eddl.dir/src/net/netloss.cpp.o
[ 65%] Building CXX object CMakeFiles/eddl.dir/src/optimizers/optim.cpp.o
[ 66%] Building CXX object CMakeFiles/eddl.dir/src/optimizers/optim_adadelta.cpp.o
[ 66%] Building CXX object CMakeFiles/eddl.dir/src/optimizers/optim_adagrad.cpp.o
[ 67%] Building CXX object CMakeFiles/eddl.dir/src/optimizers/optim_adam.cpp.o
[ 67%] Building CXX object CMakeFiles/eddl.dir/src/optimizers/optim_adamax.cpp.o
[ 68%] Building CXX object CMakeFiles/eddl.dir/src/optimizers/optim_nadam.cpp.o
[ 68%] Building CXX object CMakeFiles/eddl.dir/src/optimizers/optim_rmsprop.cpp.o
[ 69%] Building CXX object CMakeFiles/eddl.dir/src/optimizers/optim_sgd.cpp.o
[ 69%] Building CXX object CMakeFiles/eddl.dir/src/regularizers/regularizer.cpp.o
[ 70%] Building CXX object CMakeFiles/eddl.dir/src/regularizers/regularizer_l1.cpp.o
[ 70%] Building CXX object CMakeFiles/eddl.dir/src/regularizers/regularizer_l1_l2.cpp.o
[ 71%] Building CXX object CMakeFiles/eddl.dir/src/regularizers/regularizer_l2.cpp.o
[ 71%] Building CXX object CMakeFiles/eddl.dir/src/tensor/cnpy/cnpy.cpp.o
[ 72%] Building CXX object CMakeFiles/eddl.dir/src/tensor/nn/tensor_activations.cpp.o
[ 72%] Building CXX object CMakeFiles/eddl.dir/src/tensor/nn/tensor_conv.cpp.o
[ 73%] Building CXX object CMakeFiles/eddl.dir/src/tensor/nn/tensor_core_nn.cpp.o
[ 73%] Building CXX object CMakeFiles/eddl.dir/src/tensor/nn/tensor_losses.cpp.o
[ 74%] Building CXX object CMakeFiles/eddl.dir/src/tensor/nn/tensor_metrics.cpp.o
[ 74%] Building CXX object CMakeFiles/eddl.dir/src/tensor/nn/tensor_pool.cpp.o
[ 75%] Building CXX object CMakeFiles/eddl.dir/src/tensor/tensor.cpp.o
[ 75%] Building CXX object CMakeFiles/eddl.dir/src/tensor/tensor_comparison.cpp.o
[ 76%] Building CXX object CMakeFiles/eddl.dir/src/tensor/tensor_core.cpp.o
[ 76%] Building CXX object CMakeFiles/eddl.dir/src/tensor/tensor_create.cpp.o
[ 77%] Building CXX object CMakeFiles/eddl.dir/src/tensor/tensor_da.cpp.o
[ 77%] Building CXX object CMakeFiles/eddl.dir/src/tensor/tensor_generator.cpp.o
[ 78%] Building CXX object CMakeFiles/eddl.dir/src/tensor/tensor_math.cpp.o
[ 78%] Building CXX object CMakeFiles/eddl.dir/src/tensor/tensor_reduction.cpp.o
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/nn/tensor_core_nn.cpp: In member function ‘void Tensor::resize(int, float*)’:
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/nn/tensor_core_nn.cpp:37:47: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
           ptr = get_fmem(size,"Tensor::resize");
                                               ^
[ 79%] Building CXX object CMakeFiles/eddl.dir/src/tensor/tensor_serialization.cpp.o
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor.cpp: In member function ‘void Tensor::updateData(float*)’:
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor.cpp:104:82: warning: deprecated conversion from string constant to ‘char*’ [-Wwrite-strings]
         if (fptr==nullptr) { this->ptr = get_fmem(this->size,"Tensor::updateData"); }
                                                                                  ^
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp: In static member function ‘static Tensor* Tensor::load_from_img(const string&, const string&)’:
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:133:45: error: expected unqualified-id before ‘&’ token
     } catch(const std::bad_array_new_length &e) {
                                             ^
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:133:45: error: expected ‘)’ before ‘&’ token
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:133:45: error: expected ‘{’ before ‘&’ token
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:133:46: error: ‘e’ was not declared in this scope
     } catch(const std::bad_array_new_length &e) {
                                              ^
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:133:47: error: expected ‘;’ before ‘)’ token
     } catch(const std::bad_array_new_length &e) {
                                               ^
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp: In static member function ‘static Tensor* Tensor::load_from_txt(std::ifstream&, char, int)’:
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:169:45: error: expected unqualified-id before ‘&’ token
     } catch(const std::bad_array_new_length &e) {
                                             ^
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:169:45: error: expected ‘)’ before ‘&’ token
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:169:45: error: expected ‘{’ before ‘&’ token
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:169:46: error: ‘e’ was not declared in this scope
     } catch(const std::bad_array_new_length &e) {
                                              ^
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:169:47: error: expected ‘;’ before ‘)’ token
     } catch(const std::bad_array_new_length &e) {
                                               ^
make[2]: *** [CMakeFiles/eddl.dir/src/tensor/tensor_serialization.cpp.o] Error 1
make[1]: *** [CMakeFiles/eddl.dir/all] Error 2
make: *** [all] Error 2
[  1%] Building CXX object CMakeFiles/eddl.dir/src/tensor/tensor_serialization.cpp.o
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp: In static member function ‘static Tensor* Tensor::load_from_img(const string&, const string&)’:
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:133:45: error: expected unqualified-id before ‘&’ token
     } catch(const std::bad_array_new_length &e) {
                                             ^
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:133:45: error: expected ‘)’ before ‘&’ token
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:133:45: error: expected ‘{’ before ‘&’ token
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:133:46: error: ‘e’ was not declared in this scope
     } catch(const std::bad_array_new_length &e) {
                                              ^
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:133:47: error: expected ‘;’ before ‘)’ token
     } catch(const std::bad_array_new_length &e) {
                                               ^
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp: In static member function ‘static Tensor* Tensor::load_from_txt(std::ifstream&, char, int)’:
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:169:45: error: expected unqualified-id before ‘&’ token
     } catch(const std::bad_array_new_length &e) {
                                             ^
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:169:45: error: expected ‘)’ before ‘&’ token
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:169:45: error: expected ‘{’ before ‘&’ token
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:169:46: error: ‘e’ was not declared in this scope
     } catch(const std::bad_array_new_length &e) {
                                              ^
/home/oliveri/oliveri/Projet_de_Batchelor/repo/pyeddl/third_party/eddl/src/tensor/tensor_serialization.cpp:169:47: error: expected ‘;’ before ‘)’ token
     } catch(const std::bad_array_new_length &e) {
                                               ^
make[2]: *** [CMakeFiles/eddl.dir/src/tensor/tensor_serialization.cpp.o] Error 1
make[1]: *** [CMakeFiles/eddl.dir/all] Error 2
make: *** [all] Error 2

Thank you in advance for your help.

g++11

Cmake has to create a Makefile that use g++11 in order to avoid these errors:

/Users/rparedes/GITHUB/EDDLL/src/layers/../tensor.h:111:27: error: unknown type name 'initializer_list'
ConvolDescriptor(const initializer_list& ks,const initializer_list& st, string p);

Bias and Kernel regularisation and initialisation for Conv Layer

Good Afternoon,
I saw in the documentation that Regulisers and Initialisers are implemented under the form of separate layers and not as parameters to the Conv layer. There are however no examples showing how the weights could be regularised and initialised neither for the kernel nor for the bias of the Conv layer.
Could you please give me an example of how to implement this with the existing layers?
Thank you for your help.

"double free or corruption" error still present

Even though destructor implementation has changed after #46 was closed, "double free or corruption" errors are still present. Here is a C++ program that exposes the problem in eddl @ 7785f88:

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

#include <eddl/apis/eddl.h>

using namespace eddl;

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

  int num_classes = 10;

  layer in = Input({784});
  layer r1 = Reshape(in, {1,28,28});

  layer c1 = Conv(r1, 16, {3,3}, {1,1});
  layer a1 = Activation(c1, "relu");
  layer b1 = BatchNormalization(a1);
  layer m1 = MaxPool(b1, {2, 2});

  layer c2 = Conv(m1, 16, {3,3}, {1,1});
  layer a2 = Activation(c2, "relu");
  layer b2 = BatchNormalization(a2);
  layer m2 = MaxPool(b2, {2, 2});

  layer c3 = Conv(m2, 16, {3,3}, {1,1});
  layer a3 = Activation(c3, "relu");
  layer b3 = BatchNormalization(a3);
  layer m3 = MaxPool(b3, {2, 2});

  layer c4 = Conv(m3, 16, {3,3}, {1,1});
  layer a4 = Activation(c4, "relu");
  layer b4 = BatchNormalization(a4);
  layer m4 = MaxPool(b4, {2, 2});

  layer r2 = Reshape(m4, {-1});
  layer d1 = Dense(r2, 256);
  layer a5 = Activation(d1, "relu");
  layer d2 = Dense(a5, num_classes);
  layer out = Activation(d2, "softmax");

  model net=Model({in},{out});

  build(net,
    sgd(0.01, 0.9),
    {"soft_cross_entropy"},
    {"categorical_accuracy"},
    CS_CPU(4)
  );
  cout << summary(net) << endl;

  delete out;
  delete d2;
  delete a5;
  delete d1;
  delete r2;

  delete m4;
  delete b4;
  delete a4;
  delete c4;

  delete m3;
  delete b3;
  delete a3;
  delete c3;

  delete m2;
  delete b2;
  delete a2;
  delete c2;

  delete m1;
  delete b1;
  delete a1;
  delete c1;

  delete r1;
  delete in;
}

The output (code instrumented with prints) ends with:

[...]
Destroying Layer: 'reshape1'
  delete output
    destroying Tensor
      delete tsem
  delete delta
    destroying Tensor
      delete tsem
  delete target
Done: 'reshape1'
    destroying Tensor
double free or corruption (!prev)
Aborted (core dumped)

Cannot build by using cmake 3.10

After the commit 6b55821, changes to CMakeLists.txt prevent building code by using cmake 3.10.
I got this error:

Policy "CMP0074" is not known to this version of CMake

Automatically push the documentation to the cloud

Right now, I have to copy-paste the sphinx documentation I build locally, to a GitHub repo so that it can be online though Github Pages: https://github.com/deephealthproject/eddl

Since this can be easily automated through Jenkins (...or ReadTheDocs), I think we should add a few lines to our Jenkins file to make it work (like we did with doxygen). I prefer ReadTheDocs but I'm not sure if it can deal with C++ stuff.

Our sphinx documentation is augmented with Doxygen through Breathe, so you need to build both:

cd docs/doxygen
doxygen

cd docs/source
make html

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.