mirror of
https://github.com/augustin64/projet-tipe
synced 2025-04-22 05:23:53 +02:00
Add colors.h
This commit is contained in:
parent
1d0bc02f7b
commit
577954908c
@ -1,10 +1,12 @@
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "../colors.h"
|
||||
#include "include/initialisation.h"
|
||||
|
||||
|
||||
void initialisation_1d_matrix(int initialisation, float* matrix, int rows, int n) { // TODO
|
||||
printf("\033[33;1m[WARNING]\033[0m Appel de initialisation_1d_matrix, incomplet\n");
|
||||
printf_warning("Appel de initialisation_1d_matrix, incomplet\n");
|
||||
float lower_bound = -6/sqrt((double)n);
|
||||
float distance = -lower_bound-lower_bound;
|
||||
for (int i=0; i < rows; i++) {
|
||||
@ -13,7 +15,7 @@ void initialisation_1d_matrix(int initialisation, float* matrix, int rows, int n
|
||||
}
|
||||
|
||||
void initialisation_2d_matrix(int initialisation, float** matrix, int rows, int columns, int n) { // TODO
|
||||
printf("\033[33;1m[WARNING]\033[0m Appel de initialisation_2d_matrix, incomplet\n");
|
||||
printf_warning("Appel de initialisation_2d_matrix, incomplet\n");
|
||||
float lower_bound = -6/sqrt((double)n);
|
||||
float distance = -lower_bound-lower_bound;
|
||||
for (int i=0; i < rows; i++) {
|
||||
@ -24,7 +26,7 @@ void initialisation_2d_matrix(int initialisation, float** matrix, int rows, int
|
||||
}
|
||||
|
||||
void initialisation_3d_matrix(int initialisation, float*** matrix, int depth, int rows, int columns, int n) { // TODO
|
||||
printf("\033[33;1m[WARNING]\033[0m Appel de initialisation_3d_matrix, incomplet\n");
|
||||
printf_warning("Appel de initialisation_3d_matrix, incomplet\n");
|
||||
float lower_bound = -6/sqrt((double)n);
|
||||
float distance = -lower_bound-lower_bound;
|
||||
for (int i=0; i < depth; i++) {
|
||||
@ -37,7 +39,7 @@ void initialisation_3d_matrix(int initialisation, float*** matrix, int depth, in
|
||||
}
|
||||
|
||||
void initialisation_4d_matrix(int initialisation, float**** matrix, int rows, int columns, int rows1, int columns1, int n) { // TODO
|
||||
printf("\033[33;1m[WARNING]\033[0m Appel de initialisation_4d_matrix, incomplet\n");
|
||||
printf_warning("Appel de initialisation_4d_matrix, incomplet\n");
|
||||
float lower_bound = -6/sqrt((double)n);
|
||||
float distance = -lower_bound-lower_bound;
|
||||
for (int i=0; i < rows; i++) {
|
||||
|
@ -2,6 +2,8 @@
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <float.h>
|
||||
|
||||
#include "../colors.h"
|
||||
#include "include/initialisation.h"
|
||||
#include "function.c"
|
||||
#include "creation.c"
|
||||
@ -79,7 +81,7 @@ void forward_propagation(Network* network) {
|
||||
}
|
||||
|
||||
void backward_propagation(Network* network, float wanted_number) { // TODO
|
||||
printf("\033[33;1m[WARNING]\033[0m Appel de backward_propagation, incomplet\n");
|
||||
printf_warning("Appel de backward_propagation, incomplet\n");
|
||||
float* wanted_output = generate_wanted_output(wanted_number);
|
||||
int n = network->size-1;
|
||||
float loss = compute_cross_entropy_loss(network->input[n][0][0], wanted_output, network->width[n]);
|
||||
|
@ -1,9 +1,11 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "../colors.h"
|
||||
#include "include/make.h"
|
||||
|
||||
void make_convolution(float*** input, Kernel_cnn* kernel, float*** output, int output_dim) {
|
||||
// TODO, MISS CONDITIONS ON THE CONVOLUTION
|
||||
printf("\033[33;1m[WARNING]\033[0m Appel de make_convolution, incomplet\n");
|
||||
printf_warning("Appel de make_convolution, incomplet\n");
|
||||
float f;
|
||||
int n = kernel->k_size;
|
||||
printf("Convolution output: %dx%dx%d, %dx%dx%d\n", kernel->columns, output_dim, output_dim, kernel->rows, n, n);
|
||||
@ -27,7 +29,7 @@ void make_convolution(float*** input, Kernel_cnn* kernel, float*** output, int o
|
||||
|
||||
void make_average_pooling(float*** input, float*** output, int size, int output_depth, int output_dim) {
|
||||
// TODO, MISS CONDITIONS ON THE POOLING
|
||||
printf("\033[33;1m[WARNING]\033[0m Appel de make_average_pooling, incomplet\n");
|
||||
printf_warning("Appel de make_average_pooling, incomplet\n");
|
||||
float average;
|
||||
int n = size*size;
|
||||
for (int i=0; i < output_depth; i++) {
|
||||
@ -47,7 +49,7 @@ void make_average_pooling(float*** input, float*** output, int size, int output_
|
||||
|
||||
void make_average_pooling_flattened(float*** input, float* output, int size, int input_depth, int input_dim) {
|
||||
if ((input_depth*input_dim*input_dim) % (size*size) != 0) {
|
||||
printf("Erreur, deux layers non compatibles avec un average pooling flattened");
|
||||
printf_error("Deux layers non compatibles avec un average pooling flattened");
|
||||
return;
|
||||
}
|
||||
float average;
|
||||
|
@ -119,7 +119,7 @@ Network* read_network(char* filename) {
|
||||
FILE *ptr;
|
||||
Network* network = (Network*)malloc(sizeof(Network));
|
||||
// TODO: malloc pour network -> input
|
||||
printf("\033[33;1m[WARNING]\033[0m Chargement depuis un fichier, network->input ne sera pas alloué\n");
|
||||
printf_warning("Chargement depuis un fichier, network->input ne sera pas alloué\n");
|
||||
|
||||
ptr = fopen(filename, "rb");
|
||||
|
||||
|
34
src/colors.h
Normal file
34
src/colors.h
Normal file
@ -0,0 +1,34 @@
|
||||
#ifndef DEF_COLORS_H
|
||||
#define DEF_COLORS_H
|
||||
|
||||
#define RESET "\033[0m"
|
||||
#define BLACK "\033[30m" /* Black */
|
||||
#define RED "\033[31m" /* Red */
|
||||
#define GREEN "\033[32m" /* Green */
|
||||
#define YELLOW "\033[33m" /* Yellow */
|
||||
#define BLUE "\033[34m" /* Blue */
|
||||
#define MAGENTA "\033[35m" /* Magenta */
|
||||
#define CYAN "\033[36m" /* Cyan */
|
||||
#define WHITE "\033[37m" /* White */
|
||||
#define BOLDBLACK "\033[1m\033[30m" /* Bold Black */
|
||||
#define BOLDRED "\033[1m\033[31m" /* Bold Red */
|
||||
#define BOLDGREEN "\033[1m\033[32m" /* Bold Green */
|
||||
#define BOLDYELLOW "\033[1m\033[33m" /* Bold Yellow */
|
||||
#define BOLDBLUE "\033[1m\033[34m" /* Bold Blue */
|
||||
#define BOLDMAGENTA "\033[1m\033[35m" /* Bold Magenta */
|
||||
#define BOLDCYAN "\033[1m\033[36m" /* Bold Cyan */
|
||||
#define BOLDWHITE "\033[1m\033[37m" /* Bold White */
|
||||
|
||||
void printf_error(char* string) {
|
||||
printf(BOLDRED "[ ERROR ]" RESET " %s", string);
|
||||
}
|
||||
|
||||
void printf_warning(char* string) {
|
||||
printf(BOLDYELLOW "[WARNING]" RESET " %s", string);
|
||||
}
|
||||
|
||||
void printf_info(char* string) {
|
||||
printf(BOLDBLUE "[ INFO ]" RESET " %s", string);
|
||||
}
|
||||
|
||||
#endif
|
@ -3,6 +3,7 @@
|
||||
#include <stdint.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "../src/colors.h"
|
||||
#include "../src/cnn/neuron_io.c"
|
||||
#include "../src/cnn/creation.c"
|
||||
|
||||
@ -22,9 +23,13 @@ int main() {
|
||||
printf("OK\n");
|
||||
|
||||
/*
|
||||
printf("Réécriture du nouveau réseau\n");
|
||||
write_network(".test-cache/cnn_neuron_io_2.bin", network2);
|
||||
printf("Vérification de l'égalité des réseaux\n");
|
||||
if (! equals_networks(network, network2)) {
|
||||
printf_error("Les deux réseaux obtenus ne sont pas égaux.\n");
|
||||
exit(1);
|
||||
}
|
||||
printf("OK\n");
|
||||
*/
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user