mirror of
https://github.com/augustin64/projet-tipe
synced 2025-01-23 15:16:26 +01:00
Update neuron_io.c to save larger networks
This commit is contained in:
parent
00ae08891d
commit
16a9cafc18
29
.vscode/launch.json
vendored
29
.vscode/launch.json
vendored
@ -174,6 +174,35 @@
|
|||||||
],
|
],
|
||||||
"preLaunchTask": "build-cnn"
|
"preLaunchTask": "build-cnn"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "cnn/main save-network",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/build/cnn-main",
|
||||||
|
"args": [
|
||||||
|
"train",
|
||||||
|
"--dataset",
|
||||||
|
"jpg",
|
||||||
|
"--datadir",
|
||||||
|
"data/50States10K/test",
|
||||||
|
"--epochs",
|
||||||
|
"0"
|
||||||
|
],
|
||||||
|
"stopAtEntry": true,
|
||||||
|
"cwd": "${workspaceFolder}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": false,
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "/usr/bin/gdb",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"description": "Enable pretty-printing for gdb",
|
||||||
|
"text": "-enable-pretty-printing",
|
||||||
|
"ignoreFailures": false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"preLaunchTask": "build-cnn"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "cnn/main dev-conv",
|
"name": "cnn/main dev-conv",
|
||||||
"type": "cppdbg",
|
"type": "cppdbg",
|
||||||
|
@ -81,16 +81,20 @@ void write_couche(Network* network, int indice_couche, int type_couche, FILE* pt
|
|||||||
fwrite(pre_buffer, sizeof(pre_buffer), 1, ptr);
|
fwrite(pre_buffer, sizeof(pre_buffer), 1, ptr);
|
||||||
|
|
||||||
// Écriture du corps
|
// Écriture du corps
|
||||||
float buffer[cnn->columns*(cnn->k_size*cnn->k_size*cnn->rows+output_dim*output_dim)];
|
// We need to split in small buffers to keep some free memory in the computer
|
||||||
|
|
||||||
for (int i=0; i < cnn->columns; i++) {
|
for (int i=0; i < cnn->columns; i++) {
|
||||||
|
indice_buffer = 0;
|
||||||
|
float buffer[output_dim*output_dim];
|
||||||
for (int j=0; j < output_dim; j++) {
|
for (int j=0; j < output_dim; j++) {
|
||||||
for (int k=0; k < output_dim; k++) {
|
for (int k=0; k < output_dim; k++) {
|
||||||
bufferAdd(cnn->bias[i][j][k]);
|
bufferAdd(cnn->bias[i][j][k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fwrite(buffer, sizeof(buffer), 1, ptr);
|
||||||
}
|
}
|
||||||
for (int i=0; i < cnn->rows; i++) {
|
for (int i=0; i < cnn->rows; i++) {
|
||||||
|
indice_buffer = 0;
|
||||||
|
float buffer[cnn->columns*cnn->k_size*cnn->k_size];
|
||||||
for (int j=0; j < cnn->columns; j++) {
|
for (int j=0; j < cnn->columns; j++) {
|
||||||
for (int k=0; k < cnn->k_size; k++) {
|
for (int k=0; k < cnn->k_size; k++) {
|
||||||
for (int l=0; l < cnn->k_size; l++) {
|
for (int l=0; l < cnn->k_size; l++) {
|
||||||
@ -98,8 +102,8 @@ void write_couche(Network* network, int indice_couche, int type_couche, FILE* pt
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fwrite(buffer, sizeof(buffer), 1, ptr);
|
fwrite(buffer, sizeof(buffer), 1, ptr);
|
||||||
|
}
|
||||||
} else if (type_couche == 1) { // Cas du NN
|
} else if (type_couche == 1) { // Cas du NN
|
||||||
Kernel_nn* nn = kernel->nn;
|
Kernel_nn* nn = kernel->nn;
|
||||||
|
|
||||||
@ -112,16 +116,20 @@ void write_couche(Network* network, int indice_couche, int type_couche, FILE* pt
|
|||||||
fwrite(pre_buffer, sizeof(pre_buffer), 1, ptr);
|
fwrite(pre_buffer, sizeof(pre_buffer), 1, ptr);
|
||||||
|
|
||||||
// Écriture du corps
|
// Écriture du corps
|
||||||
float buffer[(1+nn->input_units)*nn->output_units];
|
float buffer[nn->output_units];
|
||||||
for (int i=0; i < nn->output_units; i++) {
|
for (int i=0; i < nn->output_units; i++) {
|
||||||
bufferAdd(nn->bias[i]);
|
bufferAdd(nn->bias[i]);
|
||||||
}
|
}
|
||||||
|
fwrite(buffer, sizeof(buffer), 1, ptr);
|
||||||
|
|
||||||
for (int i=0; i < nn->input_units; i++) {
|
for (int i=0; i < nn->input_units; i++) {
|
||||||
|
indice_buffer = 0;
|
||||||
|
float buffer[nn->output_units];
|
||||||
for (int j=0; j < nn->output_units; j++) {
|
for (int j=0; j < nn->output_units; j++) {
|
||||||
bufferAdd(nn->weights[i][j]);
|
bufferAdd(nn->weights[i][j]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
fwrite(buffer, sizeof(buffer), 1, ptr);
|
fwrite(buffer, sizeof(buffer), 1, ptr);
|
||||||
|
}
|
||||||
} else if (type_couche == 2) { // Cas du Pooling Layer
|
} else if (type_couche == 2) { // Cas du Pooling Layer
|
||||||
uint32_t pre_buffer[2];
|
uint32_t pre_buffer[2];
|
||||||
pre_buffer[0] = kernel->linearisation;
|
pre_buffer[0] = kernel->linearisation;
|
||||||
|
Loading…
Reference in New Issue
Block a user