push iniziale
This commit is contained in:
11
cifar-10-batches/batches.meta.txt
Normal file
11
cifar-10-batches/batches.meta.txt
Normal file
@@ -0,0 +1,11 @@
|
||||
airplane
|
||||
automobile
|
||||
bird
|
||||
cat
|
||||
deer
|
||||
dog
|
||||
frog
|
||||
horse
|
||||
ship
|
||||
truck
|
||||
|
||||
BIN
cifar-10-batches/data_batch_1.bin
Normal file
BIN
cifar-10-batches/data_batch_1.bin
Normal file
Binary file not shown.
61826
cifar-10-batches/data_batch_2.bin
Normal file
61826
cifar-10-batches/data_batch_2.bin
Normal file
File diff suppressed because one or more lines are too long
BIN
cifar-10-batches/data_batch_3.bin
Normal file
BIN
cifar-10-batches/data_batch_3.bin
Normal file
Binary file not shown.
BIN
cifar-10-batches/data_batch_4.bin
Normal file
BIN
cifar-10-batches/data_batch_4.bin
Normal file
Binary file not shown.
61291
cifar-10-batches/data_batch_5.bin
Normal file
61291
cifar-10-batches/data_batch_5.bin
Normal file
File diff suppressed because one or more lines are too long
1
cifar-10-batches/readme.html
Normal file
1
cifar-10-batches/readme.html
Normal file
@@ -0,0 +1 @@
|
||||
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.cs.toronto.edu/~kriz/cifar.html">
|
||||
BIN
cifar-10-batches/test_batch.bin
Normal file
BIN
cifar-10-batches/test_batch.bin
Normal file
Binary file not shown.
58
percettroni.h
Normal file
58
percettroni.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
Definisco i percettroni della rete neurale per il dataset CIFAR10
|
||||
Struttura della rete:
|
||||
Livello 1: 256 percettroni con 3072 input ciascuno
|
||||
Livello 2: 128 percettroni con 256 input ciascuno
|
||||
Livello output: 10 percettroni con 128 input ciascuno
|
||||
|
||||
In output ci sono 10 percettroni, ognuno di essi è associato ad una categoria del CIFAR10. Alla fine dell'addestramento, la previsione sarà
|
||||
data dal percettrone di output che avrà il valore 1 rispetto agli altri 9.
|
||||
*/
|
||||
#include<stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#define INPUT_LIV1 3072
|
||||
#define INPUT_LIV2 256
|
||||
#define INPUT_LIV3 128
|
||||
|
||||
double LRE = 0.2;
|
||||
|
||||
typedef struct {
|
||||
double *pesi;
|
||||
double bias;
|
||||
double lre;
|
||||
} Percettrone;
|
||||
|
||||
double randomico();
|
||||
void inzializza_percettrone(Percettrone*, int);
|
||||
double funzione_sigmoide(Percettrone, int[], int);
|
||||
|
||||
double randomico() {
|
||||
// Genero numeri nell'intervallo [-1,1]
|
||||
return ((double)(rand() % 101 * 0.01 * 2 ) -1);
|
||||
}
|
||||
|
||||
void inizializza_percettrone(Percettrone *p, int n_pesi) {
|
||||
p->pesi = (double*)malloc(sizeof(double) * n_pesi );
|
||||
for(int i = 0; i < n_pesi; i++)
|
||||
p->pesi[i] = randomico();
|
||||
|
||||
p->bias = randomico();
|
||||
p->lre = LRE;
|
||||
}
|
||||
|
||||
double funzione_sigmoide(Percettrone p, int valori[], int n_input) {
|
||||
|
||||
double sommatoria = 0.0;
|
||||
for(int i = 0; i < n_input; i++) {
|
||||
sommatoria += (valori[i] * p.pesi[i]);
|
||||
}
|
||||
|
||||
double funzione = sommatoria + p.bias;
|
||||
double potenza_e = exp(-funzione);
|
||||
|
||||
//formula sigmoide
|
||||
double risultato = 1 / ( 1 + potenza_e);
|
||||
|
||||
return risultato;
|
||||
}
|
||||
BIN
rete_cifar10
Executable file
BIN
rete_cifar10
Executable file
Binary file not shown.
33
rete_cifar10.c
Normal file
33
rete_cifar10.c
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
#include "percettroni.h"
|
||||
|
||||
#define PERCETTRONI_1 256
|
||||
#define PERCETTRONI_2 128
|
||||
#define PERCETTRONI_OUT 10
|
||||
|
||||
void main() {
|
||||
srand(time(NULL));
|
||||
|
||||
Percettrone livello_uno[PERCETTRONI_1];
|
||||
Percettrone livello_due[PERCETTRONI_2];
|
||||
Percettrone livello_out[PERCETTRONI_OUT];
|
||||
|
||||
for(int i = 0; i < PERCETTRONI_1; i++) {
|
||||
inizializza_percettrone(&livello_uno[i], INPUT_LIV1);
|
||||
if(i < PERCETTRONI_2) {
|
||||
inizializza_percettrone(&livello_due[i], INPUT_LIV2);
|
||||
if(i < PERCETTRONI_OUT)
|
||||
inizializza_percettrone(&livello_out[i], INPUT_LIV3);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < PERCETTRONI_1; i++) {
|
||||
printf("\nPercettrone esterno %d: w78: %f, bias: %f",i, livello_uno[i].pesi[77], livello_uno[i].bias);
|
||||
if(i < PERCETTRONI_2) {
|
||||
printf("\n\tPercettrone interno %d: w78: %f, bias: %f", i, livello_due[i].pesi[77], livello_due[i].bias);
|
||||
if(i < PERCETTRONI_OUT)
|
||||
printf("\n\t\tPercettrone output %d: w78: %f, bias: %f", i, livello_out[i].pesi[77], livello_out[i].bias);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user