2023-02-05 16:21:41 +01:00
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "include/free.h"
|
|
|
|
#include "include/struct.h"
|
2023-02-28 13:14:51 +01:00
|
|
|
#include "../include/colors.h"
|
2023-02-05 16:21:41 +01:00
|
|
|
#include "include/neuron_io.h"
|
|
|
|
|
|
|
|
|
|
|
|
void help(char* call) {
|
|
|
|
printf("Usage: %s ( print-poids-kernel-cnn ) [OPTIONS]\n\n", call);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void print_poids_ker_cnn(char* modele) {
|
|
|
|
Network* network = read_network(modele);
|
|
|
|
int vus = 0;
|
|
|
|
|
|
|
|
printf("{\n");
|
|
|
|
for (int i=0; i < network->max_size-1; i++) {
|
|
|
|
Kernel_cnn* kernel_cnn = network->kernel[i]->cnn;
|
|
|
|
if (!(!kernel_cnn)) {
|
|
|
|
if (vus != 0) {
|
|
|
|
printf(",");
|
|
|
|
}
|
|
|
|
vus++;
|
|
|
|
printf("\t\"%d\":[\n", i);
|
|
|
|
for (int i=0; i < kernel_cnn->rows; i++) {
|
|
|
|
printf("\t\t[\n");
|
|
|
|
for (int j=0; j < kernel_cnn->columns; j++) {
|
|
|
|
printf("\t\t\t[\n");
|
|
|
|
for (int k=0; k < kernel_cnn->k_size; k++) {
|
|
|
|
printf("\t\t\t\t[");
|
|
|
|
for (int l=0; l < kernel_cnn->k_size; l++) {
|
2023-02-19 13:38:33 +01:00
|
|
|
printf("%lf", kernel_cnn->weights[i][j][k][l]);
|
2023-02-05 16:21:41 +01:00
|
|
|
if (l != kernel_cnn->k_size-1) {
|
|
|
|
printf(", ");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf(" ]");
|
|
|
|
if (k != kernel_cnn->k_size-1) {
|
|
|
|
printf(",");
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
printf("\t\t\t]");
|
|
|
|
if (j != kernel_cnn->columns-1) {
|
|
|
|
printf(",");
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
printf("\t\t]");
|
|
|
|
if (i != kernel_cnn->rows-1) {
|
|
|
|
printf(",");
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
|
|
|
printf("\t]\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
printf("}\n");
|
|
|
|
|
|
|
|
free_network(network);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
if (argc < 2) {
|
2023-02-28 13:14:51 +01:00
|
|
|
printf_error("Pas d'action spécifiée\n");
|
2023-02-05 16:21:41 +01:00
|
|
|
help(argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
if (! strcmp(argv[1], "print-poids-kernel-cnn")) {
|
|
|
|
char* modele = NULL; // Fichier contenant le modèle
|
|
|
|
int i = 2;
|
|
|
|
while (i < argc) {
|
|
|
|
if ((! strcmp(argv[i], "--modele"))||(! strcmp(argv[i], "-m"))) {
|
|
|
|
modele = argv[i+1];
|
|
|
|
i += 2;
|
|
|
|
} else {
|
2023-02-28 13:14:51 +01:00
|
|
|
printf_warning("Option choisie inconnue: ");
|
|
|
|
printf("%s\n", argv[i]);
|
2023-02-05 16:21:41 +01:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!modele) {
|
2023-02-28 13:14:51 +01:00
|
|
|
printf_error("Pas de modèle à utiliser spécifié.\n");
|
2023-02-05 16:21:41 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
print_poids_ker_cnn(modele);
|
|
|
|
return 0;
|
|
|
|
}
|
2023-02-28 13:14:51 +01:00
|
|
|
printf_error("Option choisie non reconnue: ");
|
|
|
|
printf("%s\n", argv[1]);
|
2023-02-05 16:21:41 +01:00
|
|
|
help(argv[0]);
|
|
|
|
return 1;
|
|
|
|
}
|