Compare commits

...

4 Commits

13 changed files with 182 additions and 126 deletions

View File

@ -41,7 +41,12 @@ NVCCFLAGS = -g
# -fsanitize=address -lasan # -fsanitize=address -lasan
#! WARNING: test/cnn-neuron_io fails with this option enabled #! WARNING: test/cnn-neuron_io fails with this option enabled
all: dense cnn; all: dense cnn;
# #
# Build dense # Build dense
# #
@ -61,82 +66,95 @@ $(BUILDDIR)/dense_%.o: $(DENSE_SRCDIR)/%.c $(DENSE_SRCDIR)/include/%.h
$(CC) -c $< -o $@ $(CFLAGS) $(CC) -c $< -o $@ $(CFLAGS)
# #
# Build cnn # Build cnn
# #
cnn: $(BUILDDIR)/cnn-main $(BUILDDIR)/cnn-main-cuda $(BUILDDIR)/cnn-preview $(BUILDDIR)/cnn-export; cnn: $(BUILDDIR)/cnn-main $(BUILDDIR)/cnn-main-cuda $(BUILDDIR)/cnn-preview $(BUILDDIR)/cnn-export;
$(BUILDDIR)/cnn-main: $(CNN_SRCDIR)/main.c \ $(BUILDDIR)/cnn-main: $(CNN_SRCDIR)/main.c \
$(BUILDDIR)/cnn_train.o \ $(BUILDDIR)/cnn_backpropagation.o \
$(BUILDDIR)/cnn_test_network.o \
$(BUILDDIR)/cnn_cnn.o \
$(BUILDDIR)/cnn_creation.o \
$(BUILDDIR)/cnn_initialisation.o \ $(BUILDDIR)/cnn_initialisation.o \
$(BUILDDIR)/cnn_make.o \ $(BUILDDIR)/cnn_test_network.o \
$(BUILDDIR)/cnn_convolution.o \
$(BUILDDIR)/cnn_neuron_io.o \ $(BUILDDIR)/cnn_neuron_io.o \
$(BUILDDIR)/cnn_function.o \ $(BUILDDIR)/cnn_function.o \
$(BUILDDIR)/cnn_utils.o \ $(BUILDDIR)/cnn_creation.o \
$(BUILDDIR)/cnn_models.o \
$(BUILDDIR)/cnn_update.o \ $(BUILDDIR)/cnn_update.o \
$(BUILDDIR)/cnn_train.o \
$(BUILDDIR)/cnn_utils.o \
$(BUILDDIR)/cnn_make.o \
$(BUILDDIR)/cnn_free.o \ $(BUILDDIR)/cnn_free.o \
$(BUILDDIR)/cnn_jpeg.o \ $(BUILDDIR)/cnn_jpeg.o \
$(BUILDDIR)/cnn_convolution.o \ $(BUILDDIR)/cnn_cnn.o \
$(BUILDDIR)/cnn_backpropagation.o \ \
$(BUILDDIR)/memory_management.o \ $(BUILDDIR)/memory_management.o \
$(BUILDDIR)/colors.o \ $(BUILDDIR)/colors.o \
$(BUILDDIR)/mnist.o \ $(BUILDDIR)/mnist.o \
$(BUILDDIR)/utils.o $(BUILDDIR)/utils.o
$(CC) $^ -o $@ $(CFLAGS) $(LD_CFLAGS) $(CC) $^ -o $@ $(CFLAGS) $(LD_CFLAGS)
ifdef NVCC_INSTALLED ifdef NVCC_INSTALLED
$(BUILDDIR)/cnn-main-cuda: $(BUILDDIR)/cnn_main.cuda.o \ $(BUILDDIR)/cnn-main-cuda: $(BUILDDIR)/cnn_main.cuda.o \
$(BUILDDIR)/cnn_train.cuda.o \
$(BUILDDIR)/cnn_test_network.cuda.o \
$(BUILDDIR)/cnn_cnn.cuda.o \
$(BUILDDIR)/cnn_creation.cuda.o \
$(BUILDDIR)/cnn_initialisation.cuda.o \ $(BUILDDIR)/cnn_initialisation.cuda.o \
$(BUILDDIR)/cnn_cuda_make.o \ $(BUILDDIR)/cnn_test_network.cuda.o \
$(BUILDDIR)/cnn_neuron_io.cuda.o \ $(BUILDDIR)/cnn_neuron_io.cuda.o \
$(BUILDDIR)/cnn_cuda_function.o \ $(BUILDDIR)/cnn_creation.cuda.o \
$(BUILDDIR)/cnn_utils.cuda.o \ $(BUILDDIR)/cnn_models.cuda.o \
$(BUILDDIR)/cnn_update.cuda.o \ $(BUILDDIR)/cnn_update.cuda.o \
$(BUILDDIR)/cnn_train.cuda.o \
$(BUILDDIR)/cnn_utils.cuda.o \
$(BUILDDIR)/cnn_free.cuda.o \ $(BUILDDIR)/cnn_free.cuda.o \
$(BUILDDIR)/cnn_jpeg.cuda.o \ $(BUILDDIR)/cnn_jpeg.cuda.o \
$(BUILDDIR)/cnn_cuda_convolution.o \ $(BUILDDIR)/cnn_cnn.cuda.o \
\
$(BUILDDIR)/cnn_cuda_backpropagation.o \ $(BUILDDIR)/cnn_cuda_backpropagation.o \
$(BUILDDIR)/colors.cuda.o \ $(BUILDDIR)/cnn_cuda_convolution.o \
$(BUILDDIR)/cnn_cuda_function.o \
$(BUILDDIR)/cnn_cuda_make.o \
\
$(BUILDDIR)/cuda_memory_management.o \ $(BUILDDIR)/cuda_memory_management.o \
$(BUILDDIR)/colors.cuda.o \
$(BUILDDIR)/mnist.cuda.o \ $(BUILDDIR)/mnist.cuda.o \
$(BUILDDIR)/cuda_utils.o $(BUILDDIR)/cuda_utils.o
$(NVCC) $(LD_NVCCFLAGS) $(NVCCFLAGS) $^ -o $@ $(NVCC) $(LD_NVCCFLAGS) $(NVCCFLAGS) $^ -o $@
else else
$(BUILDDIR)/cnn-main-cuda: $(BUILDDIR)/cnn-main-cuda:
@echo "$(NVCC) not found, skipping" @echo "$(NVCC) not found, skipping"
endif endif
$(BUILDDIR)/cnn-preview: $(CNN_SRCDIR)/preview.c $(BUILDDIR)/cnn_jpeg.o $(BUILDDIR)/colors.o $(BUILDDIR)/utils.o $(BUILDDIR)/cnn-preview: $(CNN_SRCDIR)/preview.c $(BUILDDIR)/cnn_jpeg.o $(BUILDDIR)/colors.o $(BUILDDIR)/utils.o
$(CC) $^ -o $@ $(CFLAGS) $(LD_CFLAGS) $(CC) $^ -o $@ $(CFLAGS) $(LD_CFLAGS)
$(BUILDDIR)/cnn-export: $(CNN_SRCDIR)/export.c \ $(BUILDDIR)/cnn-export: $(CNN_SRCDIR)/export.c \
$(BUILDDIR)/cnn_free.o \
$(BUILDDIR)/cnn_neuron_io.o \
$(BUILDDIR)/utils.o \
$(BUILDDIR)/memory_management.o \
$(BUILDDIR)/cnn_cnn.o \
$(BUILDDIR)/cnn_make.o \
$(BUILDDIR)/cnn_backpropagation.o \ $(BUILDDIR)/cnn_backpropagation.o \
$(BUILDDIR)/cnn_convolution.o \
$(BUILDDIR)/cnn_neuron_io.o \
$(BUILDDIR)/cnn_function.o \ $(BUILDDIR)/cnn_function.o \
$(BUILDDIR)/cnn_convolution.o \ $(BUILDDIR)/cnn_free.o \
$(BUILDDIR)/cnn_make.o \
$(BUILDDIR)/cnn_cnn.o \
$(BUILDDIR)/cnn_jpeg.o \
\
$(BUILDDIR)/memory_management.o \
$(BUILDDIR)/colors.o \ $(BUILDDIR)/colors.o \
$(BUILDDIR)/mnist.o \ $(BUILDDIR)/mnist.o \
$(BUILDDIR)/cnn_jpeg.o $(BUILDDIR)/utils.o
$(CC) $^ -o $@ $(CFLAGS) $(LD_CFLAGS) $(CC) $^ -o $@ $(CFLAGS) $(LD_CFLAGS)
$(BUILDDIR)/cnn_%.o: $(CNN_SRCDIR)/%.c $(CNN_SRCDIR)/include/%.h $(BUILDDIR)/cnn_%.o: $(CNN_SRCDIR)/%.c $(CNN_SRCDIR)/include/%.h
$(CC) -c $< -o $@ $(CFLAGS) $(CC) -c $< -o $@ $(CFLAGS)
$(BUILDDIR)/cnn_%.cuda.o: $(CNN_SRCDIR)/%.c $(CNN_SRCDIR)/include/%.h $(BUILDDIR)/cnn_%.cuda.o: $(CNN_SRCDIR)/%.c $(CNN_SRCDIR)/include/%.h
$(CC) -c $< -o $@ $(CFLAGS) -DUSE_CUDA -lcuda -I$(CUDA_INCLUDE) $(CC) -c $< -o $@ $(CFLAGS) -DUSE_CUDA -lcuda -I$(CUDA_INCLUDE)
ifdef NVCC_INSTALLED ifdef NVCC_INSTALLED
$(BUILDDIR)/cnn_cuda_%.o: $(CNN_SRCDIR)/%.cu $(CNN_SRCDIR)/include/%.h $(BUILDDIR)/cnn_cuda_%.o: $(CNN_SRCDIR)/%.cu $(CNN_SRCDIR)/include/%.h
$(NVCC) $(NVCCFLAGS) -c -dc $< -o $@ $(NVCC) $(NVCCFLAGS) -c -dc $< -o $@
@ -144,15 +162,20 @@ else
$(BUILDDIR)/cnn_cuda_%.o: $(CNN_SRCDIR)/%.cu $(CNN_SRCDIR)/include/%.h $(BUILDDIR)/cnn_cuda_%.o: $(CNN_SRCDIR)/%.cu $(CNN_SRCDIR)/include/%.h
@echo "$(NVCC) not found, skipping" @echo "$(NVCC) not found, skipping"
endif endif
# #
# Build general files # Build general files
# #
$(BUILDDIR)/%.o: $(COMMON_SRCDIR)/%.c $(COMMON_SRCDIR)/include/%.h $(BUILDDIR)/%.o: $(COMMON_SRCDIR)/%.c $(COMMON_SRCDIR)/include/%.h
$(CC) -c $< -o $@ $(CFLAGS) $(CC) -c $< -o $@ $(CFLAGS)
$(BUILDDIR)/%.cuda.o: $(COMMON_SRCDIR)/%.c $(COMMON_SRCDIR)/include/%.h $(BUILDDIR)/%.cuda.o: $(COMMON_SRCDIR)/%.c $(COMMON_SRCDIR)/include/%.h
$(CC) -c $< -o $@ $(CFLAGS) -DUSE_CUDA -lcuda -I$(CUDA_INCLUDE) $(CC) -c $< -o $@ $(CFLAGS) -DUSE_CUDA -lcuda -I$(CUDA_INCLUDE)
ifdef NVCC_INSTALLED ifdef NVCC_INSTALLED
$(BUILDDIR)/cuda_%.o: $(COMMON_SRCDIR)/%.cu $(COMMON_SRCDIR)/include/%.h $(BUILDDIR)/cuda_%.o: $(COMMON_SRCDIR)/%.cu $(COMMON_SRCDIR)/include/%.h
$(NVCC) $(NVCCFLAGS) -c -dc $< -o $@ $(NVCC) $(NVCCFLAGS) -c -dc $< -o $@
@ -160,6 +183,8 @@ else
@echo "$(NVCC) not found, skipping" @echo "$(NVCC) not found, skipping"
endif endif
# #
# Tests # Tests
# #
@ -207,6 +232,8 @@ $(BUILDDIR)/test-cnn_%: $(TEST_SRCDIR)/cnn_%.cu
@echo "$(NVCC) not found, skipping" @echo "$(NVCC) not found, skipping"
endif endif
# #
# Utils # Utils
# #
@ -231,6 +258,7 @@ $(CACHE_DIR)/mnist-reseau-cnn.bin: $(BUILDDIR)/cnn-main
--out $(CACHE_DIR)/mnist-reseau-cnn.bin --out $(CACHE_DIR)/mnist-reseau-cnn.bin
# #
# Clean project # Clean project
# #

View File

@ -38,6 +38,8 @@ uint32_t|linearisation|
uint32_t|k_size| uint32_t|k_size|
uint32_t|rows| uint32_t|rows|
uint32_t|columns| uint32_t|columns|
uint32_t|stride|
uint32_t|padding|
#### Si la couche est un nn: #### Si la couche est un nn:
type | nom de la variable | commentaire type | nom de la variable | commentaire
@ -52,6 +54,8 @@ type | nom de la variable | commentaire
:---:|:---:|:---: :---:|:---:|:---:
uint32_t|linearisation| uint32_t|linearisation|
uint32_t|pooling| uint32_t|pooling|
uint32_t|stride|
uint32_t|padding|
### Corps ### Corps

View File

@ -34,73 +34,6 @@ Network* create_network(int max_size, float learning_rate, int dropout, int init
return network; return network;
} }
Network* create_network_lenet5(float learning_rate, int dropout, int activation, int initialisation, int input_width, int input_depth) {
Network* network = create_network(8, learning_rate, dropout, initialisation, input_width, input_depth);
add_convolution(network, 5, 6, 1, 0, activation);
add_average_pooling(network, 2, 2, 0);
add_convolution(network, 5, 16, 1, 0, activation);
add_average_pooling(network, 2, 2, 0);
add_dense_linearisation(network, 120, activation);
add_dense(network, 84, activation);
add_dense(network, 10, SOFTMAX);
return network;
}
Network* create_network_alexnet(float learning_rate, int dropout, int activation, int initialisation, int size_output) {
Network* network = create_network(12, learning_rate, dropout, initialisation, 227, 3);
add_convolution(network, 11, 96, 4, 0, activation);
add_average_pooling(network, 3, 2, 0);
add_convolution(network, 5, 256, 1, 2, activation);
add_average_pooling(network, 3, 2, 0);
add_convolution(network, 3, 384, 1, 1, activation);
add_convolution(network, 3, 384, 1, 1, activation);
add_convolution(network, 3, 256, 1, 1, activation);
add_average_pooling(network, 3, 2, 0);
add_dense_linearisation(network, 4096, activation);
add_dense(network, 4096, activation);
add_dense(network, size_output, SOFTMAX);
return network;
}
Network* create_network_VGG16(float learning_rate, int dropout, int activation, int initialisation, int size_output) {
Network* network = create_network(23, learning_rate, dropout, initialisation, 256, 3);
add_convolution(network, 3, 64, 1, 0, activation); // Conv3-64
add_convolution(network, 3, 64, 1, 0, activation); // Conv3-64
add_average_pooling(network, 2, 2, 0); // Max Pool
add_convolution(network, 3, 128, 1, 0, activation); // Conv3-128
add_convolution(network, 1, 128, 1, 0, activation); // Conv1-128
add_average_pooling(network, 2, 2, 0); // Max Pool
add_convolution(network, 3, 256, 1, 0, activation); // Conv3-256
add_convolution(network, 3, 256, 1, 0, activation); // Conv3-256
add_convolution(network, 1, 256, 1, 0, activation); // Conv1-256
add_average_pooling(network, 2, 2, 0); // Max Pool
add_convolution(network, 3, 512, 1, 0, activation); // Conv3-512
add_convolution(network, 3, 512, 1, 0, activation); // Conv3-512
add_convolution(network, 1, 512, 1, 0, activation); // Conv1-512
add_average_pooling(network, 2, 2, 0); // Max Pool
add_convolution(network, 3, 512, 1, 0, activation); // Conv3-512
add_convolution(network, 3, 512, 1, 0, activation); // Conv3-512
add_convolution(network, 1, 512, 1, 0, activation); // Conv1-512
add_average_pooling(network, 2, 2, 0); // Max Pool
add_dense_linearisation(network, 2048, activation);
add_dense(network, 2048, activation);
add_dense(network, 256, activation);
add_dense(network, size_output, SOFTMAX);
return network;
}
Network* create_simple_one(float learning_rate, int dropout, int activation, int initialisation, int input_width, int input_depth) {
Network* network = create_network(3, learning_rate, dropout, initialisation, input_width, input_depth);
add_dense_linearisation(network, 80, activation);
add_dense(network, 10, SOFTMAX);
return network;
}
void create_a_cube_input_layer(Network* network, int pos, int depth, int dim) { void create_a_cube_input_layer(Network* network, int pos, int depth, int dim) {
network->input[pos] = (float***)nalloc(depth, sizeof(float**)); network->input[pos] = (float***)nalloc(depth, sizeof(float**));
for (int i=0; i < depth; i++) { for (int i=0; i < depth; i++) {

View File

@ -9,28 +9,6 @@
*/ */
Network* create_network(int max_size, float learning_rate, int dropout, int initialisation, int input_width, int input_depth); Network* create_network(int max_size, float learning_rate, int dropout, int initialisation, int input_width, int input_depth);
/*
* Renvoie un réseau suivant l'architecture LeNet5
*/
Network* create_network_lenet5(float learning_rate, int dropout, int activation, int initialisation, int input_width, int input_depth);
/*
* Renvoie un réseau suivant l'architecture AlexNet
* C'est à dire en entrée 3x227x227 et une sortie de taille 'size_output'
*/
Network* create_network_alexnet(float learning_rate, int dropout, int activation, int initialisation, int size_output);
/*
* Renvoie un réseau suivant l'architecture VGG16 modifiée pour prendre en entrée 3x256x256
* et une sortie de taille 'size_output'
*/
Network* create_network_VGG16(float learning_rate, int dropout, int activation, int initialisation, int size_output);
/*
* Renvoie un réseau sans convolution, similaire à celui utilisé dans src/dense
*/
Network* create_simple_one(float learning_rate, int dropout, int activation, int initialisation, int input_width, int input_depth);
/* /*
* Créé et alloue de la mémoire à une couche de type input cube * Créé et alloue de la mémoire à une couche de type input cube
*/ */

29
src/cnn/include/models.h Normal file
View File

@ -0,0 +1,29 @@
#include <stdlib.h>
#include <stdio.h>
#include "struct.h"
#ifndef DEF_MODELS_H
#define DEF_MODELS_H
/*
* Renvoie un réseau suivant l'architecture LeNet5
*/
Network* create_network_lenet5(float learning_rate, int dropout, int activation, int initialisation, int input_width, int input_depth);
/*
* Renvoie un réseau suivant l'architecture AlexNet
* C'est à dire en entrée 3x227x227 et une sortie de taille 'size_output'
*/
Network* create_network_alexnet(float learning_rate, int dropout, int activation, int initialisation, int size_output);
/*
* Renvoie un réseau suivant l'architecture VGG16 modifiée pour prendre en entrée 3x256x256
* et une sortie de taille 'size_output'
*/
Network* create_network_VGG16(float learning_rate, int dropout, int activation, int initialisation, int size_output);
/*
* Renvoie un réseau sans convolution, similaire à celui utilisé dans src/dense
*/
Network* create_simple_one(float learning_rate, int dropout, int activation, int initialisation, int input_width, int input_depth);
#endif

75
src/cnn/models.c Normal file
View File

@ -0,0 +1,75 @@
#include <stdlib.h>
#include <stdio.h>
#include "include/creation.h"
#include "include/function.h"
#include "include/struct.h"
#include "include/models.h"
Network* create_network_lenet5(float learning_rate, int dropout, int activation, int initialisation, int input_width, int input_depth) {
Network* network = create_network(8, learning_rate, dropout, initialisation, input_width, input_depth);
add_convolution(network, 5, 6, 1, 0, activation);
add_average_pooling(network, 2, 2, 0);
add_convolution(network, 5, 16, 1, 0, activation);
add_average_pooling(network, 2, 2, 0);
add_dense_linearisation(network, 120, activation);
add_dense(network, 84, activation);
add_dense(network, 10, SOFTMAX);
return network;
}
Network* create_network_alexnet(float learning_rate, int dropout, int activation, int initialisation, int size_output) {
Network* network = create_network(12, learning_rate, dropout, initialisation, 227, 3);
add_convolution(network, 11, 96, 4, 0, activation);
add_average_pooling(network, 3, 2, 0);
add_convolution(network, 5, 256, 1, 2, activation);
add_average_pooling(network, 3, 2, 0);
add_convolution(network, 3, 384, 1, 1, activation);
add_convolution(network, 3, 384, 1, 1, activation);
add_convolution(network, 3, 256, 1, 1, activation);
add_average_pooling(network, 3, 2, 0);
add_dense_linearisation(network, 4096, activation);
add_dense(network, 4096, activation);
add_dense(network, size_output, SOFTMAX);
return network;
}
Network* create_network_VGG16(float learning_rate, int dropout, int activation, int initialisation, int size_output) {
Network* network = create_network(23, learning_rate, dropout, initialisation, 256, 3);
add_convolution(network, 3, 64, 1, 0, activation); // Conv3-64
add_convolution(network, 3, 64, 1, 0, activation); // Conv3-64
add_average_pooling(network, 2, 2, 0); // Max Pool
add_convolution(network, 3, 128, 1, 0, activation); // Conv3-128
add_convolution(network, 1, 128, 1, 0, activation); // Conv1-128
add_average_pooling(network, 2, 2, 0); // Max Pool
add_convolution(network, 3, 256, 1, 0, activation); // Conv3-256
add_convolution(network, 3, 256, 1, 0, activation); // Conv3-256
add_convolution(network, 1, 256, 1, 0, activation); // Conv1-256
add_average_pooling(network, 2, 2, 0); // Max Pool
add_convolution(network, 3, 512, 1, 0, activation); // Conv3-512
add_convolution(network, 3, 512, 1, 0, activation); // Conv3-512
add_convolution(network, 1, 512, 1, 0, activation); // Conv1-512
add_average_pooling(network, 2, 2, 0); // Max Pool
add_convolution(network, 3, 512, 1, 0, activation); // Conv3-512
add_convolution(network, 3, 512, 1, 0, activation); // Conv3-512
add_convolution(network, 1, 512, 1, 0, activation); // Conv1-512
add_average_pooling(network, 2, 2, 0); // Max Pool
add_dense_linearisation(network, 2048, activation);
add_dense(network, 2048, activation);
add_dense(network, 256, activation);
add_dense(network, size_output, SOFTMAX);
return network;
}
Network* create_simple_one(float learning_rate, int dropout, int activation, int initialisation, int input_width, int input_depth) {
Network* network = create_network(3, learning_rate, dropout, initialisation, input_width, input_depth);
add_dense_linearisation(network, 80, activation);
add_dense(network, 10, SOFTMAX);
return network;
}

View File

@ -10,7 +10,8 @@
#include "include/neuron_io.h" #include "include/neuron_io.h"
#define MAGIC_NUMBER 1012 #define INITIAL_MAGIC_NUMBER 1010
#define MAGIC_NUMBER 1013 // Increment this whenever you change the code
#define CNN 0 #define CNN 0
#define NN 1 #define NN 1
@ -114,13 +115,11 @@ void write_couche(Network* network, int indice_couche, int type_couche, FILE* pt
Kernel_nn* nn = kernel->nn; Kernel_nn* nn = kernel->nn;
// Écriture du pré-corps // Écriture du pré-corps
uint32_t pre_buffer[6]; uint32_t pre_buffer[4];
pre_buffer[0] = kernel->activation; pre_buffer[0] = kernel->activation;
pre_buffer[1] = kernel->linearisation; pre_buffer[1] = kernel->linearisation;
pre_buffer[2] = nn->size_input; pre_buffer[2] = nn->size_input;
pre_buffer[3] = nn->size_output; pre_buffer[3] = nn->size_output;
pre_buffer[4] = kernel->stride;
pre_buffer[5] = kernel->padding;
fwrite(pre_buffer, sizeof(pre_buffer), 1, ptr); fwrite(pre_buffer, sizeof(pre_buffer), 1, ptr);
// Écriture du corps // Écriture du corps
@ -163,7 +162,12 @@ Network* read_network(char* filename) {
(void) !fread(&magic, sizeof(uint32_t), 1, ptr); (void) !fread(&magic, sizeof(uint32_t), 1, ptr);
if (magic != MAGIC_NUMBER) { if (magic != MAGIC_NUMBER) {
printf_error("Incorrect magic number !\n"); printf_error((char*)"Incorrect magic number !\n");
if (INITIAL_MAGIC_NUMBER < magic && magic >= INITIAL_MAGIC_NUMBER) {
printf("\tThis backup is no longer supported\n");
printf("\tnPlease update it manually or re-train the network.\n");
printf("\t(You can update it with a script or manually with a Hex Editor)\n");
}
exit(1); exit(1);
} }
@ -330,15 +334,15 @@ Kernel* read_kernel(int type_couche, int output_width, FILE* ptr) {
// Lecture du "Pré-corps" // Lecture du "Pré-corps"
kernel->nn = (Kernel_nn*)nalloc(1, sizeof(Kernel_nn)); kernel->nn = (Kernel_nn*)nalloc(1, sizeof(Kernel_nn));
kernel->cnn = NULL; kernel->cnn = NULL;
uint32_t buffer[6]; uint32_t buffer[4];
(void) !fread(&buffer, sizeof(buffer), 1, ptr); (void) !fread(&buffer, sizeof(buffer), 1, ptr);
kernel->activation = buffer[0]; kernel->activation = buffer[0];
kernel->linearisation = buffer[1]; kernel->linearisation = buffer[1];
kernel->nn->size_input = buffer[2]; kernel->nn->size_input = buffer[2];
kernel->nn->size_output = buffer[3]; kernel->nn->size_output = buffer[3];
kernel->stride = buffer[4]; kernel->padding = -1;
kernel->padding = buffer[5]; kernel->stride = -1;
// Lecture du corps // Lecture du corps
Kernel_nn* nn = kernel->nn; Kernel_nn* nn = kernel->nn;

View File

@ -8,15 +8,15 @@
#include <omp.h> #include <omp.h>
#include "../common/include/memory_management.h" #include "../common/include/memory_management.h"
#include "../common/include/colors.h"
#include "../common/include/utils.h"
#include "../common/include/mnist.h" #include "../common/include/mnist.h"
#include "include/initialisation.h" #include "include/initialisation.h"
#include "include/test_network.h" #include "include/test_network.h"
#include "include/neuron_io.h" #include "include/neuron_io.h"
#include "../common/include/colors.h"
#include "../common/include/utils.h"
#include "include/function.h" #include "include/function.h"
#include "include/creation.h"
#include "include/update.h" #include "include/update.h"
#include "include/models.h"
#include "include/utils.h" #include "include/utils.h"
#include "include/free.h" #include "include/free.h"
#include "include/jpeg.h" #include "include/jpeg.h"

View File

@ -214,6 +214,7 @@ void gree(void* ptr, bool already_freed) {
memory = free_memory(ptr, memory, already_freed); memory = free_memory(ptr, memory, already_freed);
pthread_mutex_unlock(&memory_lock); pthread_mutex_unlock(&memory_lock);
#else #else
(void)already_freed;
free(ptr); free(ptr);
#endif #endif
} }

View File

@ -214,6 +214,7 @@ void gree(void* ptr, bool already_freed) {
memory = free_memory(ptr, memory, already_freed); memory = free_memory(ptr, memory, already_freed);
pthread_mutex_unlock(&memory_lock); pthread_mutex_unlock(&memory_lock);
#else #else
(void)already_freed;
free(ptr); free(ptr);
#endif #endif
} }

View File

@ -6,6 +6,7 @@
#include "../src/common/include/colors.h" #include "../src/common/include/colors.h"
#include "../src/cnn/include/neuron_io.h" #include "../src/cnn/include/neuron_io.h"
#include "../src/cnn/include/creation.h" #include "../src/cnn/include/creation.h"
#include "../src/cnn/include/models.h"
#include "../src/cnn/include/utils.h" #include "../src/cnn/include/utils.h"
#include "../src/cnn/include/free.h" #include "../src/cnn/include/free.h"

View File

@ -5,6 +5,7 @@
#include "../src/common/include/colors.h" #include "../src/common/include/colors.h"
#include "../src/cnn/include/creation.h" #include "../src/cnn/include/creation.h"
#include "../src/cnn/include/models.h"
#include "../src/cnn/include/utils.h" #include "../src/cnn/include/utils.h"
#include "../src/cnn/include/free.h" #include "../src/cnn/include/free.h"

View File

@ -3,6 +3,7 @@
#include "../src/common/include/colors.h" #include "../src/common/include/colors.h"
#include "../src/cnn/include/creation.h" #include "../src/cnn/include/creation.h"
#include "../src/cnn/include/models.h"
#include "../src/cnn/include/utils.h" #include "../src/cnn/include/utils.h"
#include "../src/cnn/include/free.h" #include "../src/cnn/include/free.h"