mirror of
https://github.com/augustin64/projet-tipe
synced 2025-02-02 19:39:39 +01:00
Compare commits
2 Commits
b893f11da0
...
e4003aea28
Author | SHA1 | Date | |
---|---|---|---|
e4003aea28 | |||
7da6541937 |
@ -5,7 +5,6 @@
|
|||||||
#include "../include/colors.h"
|
#include "../include/colors.h"
|
||||||
|
|
||||||
#include "include/function.h"
|
#include "include/function.h"
|
||||||
#define BOUND_RELU 15
|
|
||||||
|
|
||||||
float identity(float x) {
|
float identity(float x) {
|
||||||
return x;
|
return x;
|
||||||
@ -28,7 +27,7 @@ float sigmoid_derivative(float x) {
|
|||||||
|
|
||||||
|
|
||||||
float relu(float x) {
|
float relu(float x) {
|
||||||
return fmaxf(0, fminf(x, BOUND_RELU));
|
return fmaxf(0, fminf(x, RELU_CLIP_VALUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
float relu_derivative(float x) {
|
float relu_derivative(float x) {
|
||||||
@ -40,7 +39,7 @@ float relu_derivative(float x) {
|
|||||||
|
|
||||||
float leaky_relu(float x) {
|
float leaky_relu(float x) {
|
||||||
if (x>0)
|
if (x>0)
|
||||||
return fminf(x, BOUND_RELU);
|
return fminf(x, RELU_CLIP_VALUE);
|
||||||
return x*LEAKER;
|
return x*LEAKER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
26
src/cnn/include/config.h
Normal file
26
src/cnn/include/config.h
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
#ifndef DEF_CONFIG_H
|
||||||
|
#define DEF_CONFIG_H
|
||||||
|
|
||||||
|
//* Paramètres d'entraînement
|
||||||
|
#define EPOCHS 10 // Nombre d'époques par défaut (itérations sur toutes les images)
|
||||||
|
#define BATCHES 32 // Nombre d'images à voir avant de mettre le réseau à jour
|
||||||
|
#define LEARNING_RATE 3e-4 // Taux d'apprentissage
|
||||||
|
#define USE_MULTITHREADING // Commenter pour utiliser un seul coeur durant l'apprentissage (meilleur pour des tailles de batchs traités rapidement)
|
||||||
|
|
||||||
|
|
||||||
|
//* Paramètre d'optimisation pour un dataset Jpeg
|
||||||
|
// keep images in ram e.g re-read and decompress each time
|
||||||
|
// Enabling this will lead to a large amount of ram used while economizing not that
|
||||||
|
// much computing power
|
||||||
|
// Note: 50States10K dataset is 90Go once decompressed, use with caution
|
||||||
|
//#define STORE_IMAGES_TO_RAM
|
||||||
|
|
||||||
|
|
||||||
|
//* Limite du réseau
|
||||||
|
// Des valeurs trop grandes dans le réseau risqueraient de provoquer des overflows notamment.
|
||||||
|
// On utilise donc la méthode gradient_clipping,
|
||||||
|
// qui consiste à majorer tous les biais et poids par un hyper-paramètre choisi précédemment.
|
||||||
|
// https://arxiv.org/pdf/1905.11881.pdf
|
||||||
|
#define NETWORK_CLIP_VALUE 300
|
||||||
|
|
||||||
|
#endif
|
@ -12,6 +12,9 @@
|
|||||||
|
|
||||||
#define LEAKER 0.2
|
#define LEAKER 0.2
|
||||||
|
|
||||||
|
// RELU and Leaky RELU max value
|
||||||
|
#define RELU_CLIP_VALUE 15
|
||||||
|
|
||||||
|
|
||||||
typedef float (*ptr)(float);
|
typedef float (*ptr)(float);
|
||||||
typedef ptr (*pm)();
|
typedef ptr (*pm)();
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
#ifndef JPEG_DEF_H
|
#ifndef JPEG_DEF_H
|
||||||
#define JPEG_DEF_H
|
#define JPEG_DEF_H
|
||||||
|
|
||||||
// keep images in ram vs re-read and decompress each time
|
#include "config.h"
|
||||||
// #define STORE_IMAGES_TO_RAM
|
|
||||||
// Note: in use dataset is 90Go once decompressed, use with caution
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Struct used to describe a single JPEG image
|
* Struct used to describe a single JPEG image
|
||||||
|
@ -4,10 +4,7 @@
|
|||||||
#ifndef DEF_TRAIN_H
|
#ifndef DEF_TRAIN_H
|
||||||
#define DEF_TRAIN_H
|
#define DEF_TRAIN_H
|
||||||
|
|
||||||
#define EPOCHS 10
|
#include "config.h"
|
||||||
#define BATCHES 32
|
|
||||||
#define USE_MULTITHREADING
|
|
||||||
#define LEARNING_RATE 3e-4
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -3,13 +3,7 @@
|
|||||||
#ifndef DEF_UPDATE_H
|
#ifndef DEF_UPDATE_H
|
||||||
#define DEF_UPDATE_H
|
#define DEF_UPDATE_H
|
||||||
|
|
||||||
/*
|
#include "config.h"
|
||||||
* Des valeurs trop grandes dans le réseau risqueraient de provoquer des overflows notamment.
|
|
||||||
* On utilise donc la méthode gradient_clipping,
|
|
||||||
* qui consiste à majorer tous les biais et poids par un hyper-paramètre choisi précédemment.
|
|
||||||
* https://arxiv.org/pdf/1905.11881.pdf
|
|
||||||
*/
|
|
||||||
#define CLIP_VALUE 300
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Réduit la valeur de a si abs(a) > CLIP_VALUE
|
* Réduit la valeur de a si abs(a) > CLIP_VALUE
|
||||||
|
@ -4,11 +4,11 @@
|
|||||||
#include "include/struct.h"
|
#include "include/struct.h"
|
||||||
|
|
||||||
float clip(float a) {
|
float clip(float a) {
|
||||||
if (a > CLIP_VALUE) {
|
if (a > NETWORK_CLIP_VALUE) {
|
||||||
return CLIP_VALUE;
|
return NETWORK_CLIP_VALUE;
|
||||||
}
|
}
|
||||||
if (a < -CLIP_VALUE) {
|
if (a < -NETWORK_CLIP_VALUE) {
|
||||||
return -CLIP_VALUE;
|
return -NETWORK_CLIP_VALUE;
|
||||||
}
|
}
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user