Fix abusive unnecessary use of shared memory

This commit is contained in:
augustin64 2023-02-19 10:22:22 +01:00
parent ec36801732
commit db92b367ad
2 changed files with 20 additions and 20 deletions

View File

@ -30,7 +30,7 @@ void test_network_mnist(Network* network, char* images_file, char* labels_file,
width = mnist_parameters[1]; width = mnist_parameters[1];
height = mnist_parameters[2]; height = mnist_parameters[2];
gree(mnist_parameters); free(mnist_parameters);
// Load image in the first layer of the Network // Load image in the first layer of the Network
for (int i=0; i < nb_elem; i++) { for (int i=0; i < nb_elem; i++) {
@ -47,11 +47,11 @@ void test_network_mnist(Network* network, char* images_file, char* labels_file,
} }
for (int j=0; j < height; j++) { for (int j=0; j < height; j++) {
gree(images[i][j]); free(images[i][j]);
} }
gree(images[i]); free(images[i]);
} }
gree(images); free(images);
printf("%d Images. Taux de réussite: %.2f%%\n", nb_elem, 100*accuracy/(float)nb_elem); printf("%d Images. Taux de réussite: %.2f%%\n", nb_elem, 100*accuracy/(float)nb_elem);
} }
@ -76,13 +76,13 @@ void test_network_jpg(Network* network, char* data_dir, bool preview_fails) {
accuracy++; accuracy++;
} }
gree(dataset->images[i]); free(dataset->images[i]);
} }
printf("%d Images. Taux de réussite: %.2f%%\n", dataset->numImages, 100*accuracy/(float)dataset->numImages); printf("%d Images. Taux de réussite: %.2f%%\n", dataset->numImages, 100*accuracy/(float)dataset->numImages);
gree(dataset->images); free(dataset->images);
gree(dataset->labels); free(dataset->labels);
gree(dataset); free(dataset);
} }
@ -110,7 +110,7 @@ void recognize_mnist(Network* network, char* input_file, char* out) {
width = mnist_parameters[1]; width = mnist_parameters[1];
height = mnist_parameters[2]; height = mnist_parameters[2];
gree(mnist_parameters); free(mnist_parameters);
if (! strcmp(out, "json")) { if (! strcmp(out, "json")) {
printf("{\n"); printf("{\n");
@ -148,15 +148,15 @@ void recognize_mnist(Network* network, char* input_file, char* out) {
} }
for (int j=0; j < height; j++) { for (int j=0; j < height; j++) {
gree(images[i][j]); free(images[i][j]);
} }
gree(images[i]); free(images[i]);
} }
if (! strcmp(out, "json")) { if (! strcmp(out, "json")) {
printf("}\n"); printf("}\n");
} }
gree(images); free(images);
} }
void recognize_jpg(Network* network, char* input_file, char* out) { void recognize_jpg(Network* network, char* input_file, char* out) {
@ -195,8 +195,8 @@ void recognize_jpg(Network* network, char* input_file, char* out) {
printf("}\n"); printf("}\n");
} }
gree(image->lpData); free(image->lpData);
gree(image); free(image);
} }
void recognize(int dataset_type, char* modele, char* input_file, char* out) { void recognize(int dataset_type, char* modele, char* input_file, char* out) {

View File

@ -72,7 +72,7 @@ void* train_thread(void* parameters) {
if (!param->dataset->images[index[i]]) { if (!param->dataset->images[index[i]]) {
image = loadJpegImageFile(param->dataset->fileNames[index[i]]); image = loadJpegImageFile(param->dataset->fileNames[index[i]]);
param->dataset->images[index[i]] = image->lpData; param->dataset->images[index[i]] = image->lpData;
gree(image); free(image);
} }
write_image_in_network_260(param->dataset->images[index[i]], height, width, network->input[0]); write_image_in_network_260(param->dataset->images[index[i]], height, width, network->input[0]);
forward_propagation(network); forward_propagation(network);
@ -83,7 +83,7 @@ void* train_thread(void* parameters) {
accuracy += 1.; accuracy += 1.;
} }
gree(param->dataset->images[index[i]]); free(param->dataset->images[index[i]]);
param->dataset->images[index[i]] = NULL; param->dataset->images[index[i]] = NULL;
} }
} }
@ -351,12 +351,12 @@ void train(int dataset_type, char* images_file, char* labels_file, char* data_di
if (dataset_type == 0) { if (dataset_type == 0) {
for (int i=0; i < nb_images_total; i++) { for (int i=0; i < nb_images_total; i++) {
for (int j=0; j < 28; j++) { for (int j=0; j < 28; j++) {
gree(images[i][j]); free(images[i][j]);
} }
gree(images[i]); free(images[i]);
} }
gree(images); free(images);
gree(labels); free(labels);
} else { } else {
free_dataset(dataset); free_dataset(dataset);
} }