mirror of
https://github.com/augustin64/projet-tipe
synced 2025-02-09 05:13:43 +01:00
Compare commits
No commits in common. "e4003aea28fb6ce11e4ebda5da0ddd1e2a79aae7" and "b893f11da0a47e5c49c91aa49246f76294945bfe" have entirely different histories.
e4003aea28
...
b893f11da0
@ -5,6 +5,7 @@
|
||||
#include "../include/colors.h"
|
||||
|
||||
#include "include/function.h"
|
||||
#define BOUND_RELU 15
|
||||
|
||||
float identity(float x) {
|
||||
return x;
|
||||
@ -27,7 +28,7 @@ float sigmoid_derivative(float x) {
|
||||
|
||||
|
||||
float relu(float x) {
|
||||
return fmaxf(0, fminf(x, RELU_CLIP_VALUE));
|
||||
return fmaxf(0, fminf(x, BOUND_RELU));
|
||||
}
|
||||
|
||||
float relu_derivative(float x) {
|
||||
@ -39,7 +40,7 @@ float relu_derivative(float x) {
|
||||
|
||||
float leaky_relu(float x) {
|
||||
if (x>0)
|
||||
return fminf(x, RELU_CLIP_VALUE);
|
||||
return fminf(x, BOUND_RELU);
|
||||
return x*LEAKER;
|
||||
}
|
||||
|
||||
|
@ -1,26 +0,0 @@
|
||||
#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,9 +12,6 @@
|
||||
|
||||
#define LEAKER 0.2
|
||||
|
||||
// RELU and Leaky RELU max value
|
||||
#define RELU_CLIP_VALUE 15
|
||||
|
||||
|
||||
typedef float (*ptr)(float);
|
||||
typedef ptr (*pm)();
|
||||
|
@ -1,7 +1,9 @@
|
||||
#ifndef JPEG_DEF_H
|
||||
#define JPEG_DEF_H
|
||||
|
||||
#include "config.h"
|
||||
// keep images in ram vs re-read and decompress each time
|
||||
// #define STORE_IMAGES_TO_RAM
|
||||
// Note: in use dataset is 90Go once decompressed, use with caution
|
||||
|
||||
/*
|
||||
* Struct used to describe a single JPEG image
|
||||
|
@ -4,7 +4,10 @@
|
||||
#ifndef DEF_TRAIN_H
|
||||
#define DEF_TRAIN_H
|
||||
|
||||
#include "config.h"
|
||||
#define EPOCHS 10
|
||||
#define BATCHES 32
|
||||
#define USE_MULTITHREADING
|
||||
#define LEARNING_RATE 3e-4
|
||||
|
||||
|
||||
/*
|
||||
|
@ -3,7 +3,13 @@
|
||||
#ifndef 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
|
||||
|
@ -4,11 +4,11 @@
|
||||
#include "include/struct.h"
|
||||
|
||||
float clip(float a) {
|
||||
if (a > NETWORK_CLIP_VALUE) {
|
||||
return NETWORK_CLIP_VALUE;
|
||||
if (a > CLIP_VALUE) {
|
||||
return CLIP_VALUE;
|
||||
}
|
||||
if (a < -NETWORK_CLIP_VALUE) {
|
||||
return -NETWORK_CLIP_VALUE;
|
||||
if (a < -CLIP_VALUE) {
|
||||
return -CLIP_VALUE;
|
||||
}
|
||||
return a;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user