mirror of
https://github.com/augustin64/projet-tipe
synced 2025-02-02 19:39:39 +01:00
Rename mnist out files: out/* -> out/mnist_*
This commit is contained in:
parent
f52c853f8e
commit
b12a03c1ba
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
@ -18,7 +18,7 @@ jobs:
|
|||||||
- name: run tests
|
- name: run tests
|
||||||
run: ./make.sh test run
|
run: ./make.sh test run
|
||||||
- name: mnist main test
|
- name: mnist main test
|
||||||
run: out/main train
|
run: out/mnist_main train
|
||||||
--epochs 1
|
--epochs 1
|
||||||
--images data/mnist/t10k-images-idx3-ubyte
|
--images data/mnist/t10k-images-idx3-ubyte
|
||||||
--labels data/mnist/t10k-labels-idx1-ubyte
|
--labels data/mnist/t10k-labels-idx1-ubyte
|
||||||
|
31
.vscode/tasks.json
vendored
31
.vscode/tasks.json
vendored
@ -29,32 +29,13 @@
|
|||||||
"detail": "Tâche générée par le débogueur."
|
"detail": "Tâche générée par le débogueur."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "build",
|
"label": "build",
|
||||||
"label": "C: gcc générer le fichier actif",
|
"command": "${workspaceFolder}/make.sh",
|
||||||
"command": "gcc",
|
|
||||||
"args": [
|
"args": [
|
||||||
"-g",
|
"build",
|
||||||
"${file}",
|
"all"
|
||||||
"-o",
|
]
|
||||||
"${workspaceFolder}/out/${fileBasenameNoExtension}",
|
},
|
||||||
"-lm",
|
|
||||||
"-lpthread",
|
|
||||||
"-std=c99",
|
|
||||||
"-Wall",
|
|
||||||
"-Wextra"
|
|
||||||
],
|
|
||||||
"options": {
|
|
||||||
"cwd": "${fileDirname}"
|
|
||||||
},
|
|
||||||
"problemMatcher": [
|
|
||||||
"$gcc"
|
|
||||||
],
|
|
||||||
"group": {
|
|
||||||
"kind": "build",
|
|
||||||
"isDefault": true
|
|
||||||
},
|
|
||||||
"detail": "Tâche générée par le débogueur."
|
|
||||||
}
|
|
||||||
],
|
],
|
||||||
"version": "2.0.0"
|
"version": "2.0.0"
|
||||||
}
|
}
|
70
make.sh
70
make.sh
@ -15,19 +15,19 @@ compile_cuda () {
|
|||||||
|
|
||||||
build () {
|
build () {
|
||||||
mkdir -p "$OUT"
|
mkdir -p "$OUT"
|
||||||
[[ $1 ]] || set "main"
|
[[ $1 ]] || set "mnist-main"
|
||||||
if [[ $1 == "main" ]]; then
|
if [[ $1 == "mnist-main" ]]; then
|
||||||
echo "Compilation de src/mnist/main.c"
|
echo "Compilation de src/mnist/main.c"
|
||||||
$CC src/mnist/main.c -o "$OUT/main" $FLAGS
|
$CC src/mnist/main.c -o "$OUT/mnist_main" $FLAGS
|
||||||
echo "Fait."
|
echo "Fait."
|
||||||
return 0
|
return 0
|
||||||
elif [[ $1 == "preview" ]]; then
|
elif [[ $1 == "mnist-preview" ]]; then
|
||||||
echo "Compilation de src/mnist/preview.c"
|
echo "Compilation de src/mnist/preview.c"
|
||||||
$CC src/mnist/preview.c -o "$OUT/preview_mnist" $FLAGS
|
$CC src/mnist/preview.c -o "$OUT/mnist_preview" $FLAGS
|
||||||
echo "Fait."
|
echo "Fait."
|
||||||
return 0
|
return 0
|
||||||
elif [[ $1 == "test" ]]; then
|
elif [[ $1 == "test" ]]; then
|
||||||
[[ -f "$OUT/test_"* ]] && rm "$OUT/test_"*
|
rm "$OUT/test_"* || true
|
||||||
for i in "test/"*".c"; do
|
for i in "test/"*".c"; do
|
||||||
echo "Compilation de $i"
|
echo "Compilation de $i"
|
||||||
$CC "$i" -o "$OUT/test_$(echo $i | awk -F. '{print $1}' | awk -F/ '{print $NF}')" $FLAGS
|
$CC "$i" -o "$OUT/test_$(echo $i | awk -F. '{print $1}' | awk -F/ '{print $NF}')" $FLAGS
|
||||||
@ -45,16 +45,30 @@ build () {
|
|||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
return 0
|
return 0
|
||||||
elif [[ $1 == "utils" ]]; then
|
elif [[ $1 == "mnist-utils" ]]; then
|
||||||
echo "Compilation de src/mnist/utils.c"
|
echo "Compilation de src/mnist/utils.c"
|
||||||
$CC "src/mnist/utils.c" -o "$OUT/utils" $FLAGS
|
$CC "src/mnist/utils.c" -o "$OUT/mnist_utils" $FLAGS
|
||||||
echo "Fait."
|
echo "Fait."
|
||||||
return 0
|
return 0
|
||||||
|
elif [[ $1 == "mnist" ]]; then
|
||||||
|
build mnist-main
|
||||||
|
build mnist-preview
|
||||||
|
build mnist-utils
|
||||||
|
elif [[ $1 == "cnn-main" ]]; then
|
||||||
|
echo "Compilation de src/cnn/main.c"
|
||||||
|
$CC "src/cnn/main.c" -o "$OUT/cnn_main" $FLAGS
|
||||||
|
echo "Fait."
|
||||||
|
elif [[ $1 == "cnn" ]]; then
|
||||||
|
build cnn-main
|
||||||
else
|
else
|
||||||
build main
|
echo -e "\033[1m\033[34m### Building mnist ###\033[0m"
|
||||||
build preview
|
build mnist-main
|
||||||
|
build mnist-preview
|
||||||
|
build mnist-utils
|
||||||
|
echo -e "\033[1m\033[34m### Building cnn ###\033[0m"
|
||||||
|
build cnn
|
||||||
|
echo -e "\033[1m\033[34m### Building tests ###\033[0m"
|
||||||
build test
|
build test
|
||||||
build utils
|
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -64,12 +78,12 @@ preview () {
|
|||||||
build preview
|
build preview
|
||||||
return 0
|
return 0
|
||||||
elif [[ $1 == "train" ]]; then
|
elif [[ $1 == "train" ]]; then
|
||||||
[[ -f "$OUT/preview_mnist" ]] || $0 build preview
|
[[ -f "$OUT/mnist_preview" ]] || $0 build preview
|
||||||
"$OUT/preview_mnist" data/mnist/train-images-idx3-ubyte data/mnist/train-labels-idx1-ubyte
|
"$OUT/mnist_preview" data/mnist/train-images-idx3-ubyte data/mnist/train-labels-idx1-ubyte
|
||||||
return 0
|
return 0
|
||||||
elif [[ $1 == "t10k" ]]; then
|
elif [[ $1 == "t10k" ]]; then
|
||||||
[[ -f "$OUT/preview_mnist" ]] || $0 build preview
|
[[ -f "$OUT/mnist_preview" ]] || $0 build preview
|
||||||
"$OUT/preview_mnist" data/mnist/t10k-images-idx3-ubyte data/mnist/t10k-labels-idx1-ubyte
|
"$OUT/mnist_preview" data/mnist/t10k-images-idx3-ubyte data/mnist/t10k-labels-idx1-ubyte
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@ -95,11 +109,11 @@ test () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
train () {
|
train () {
|
||||||
[[ -f "$OUT/main" ]] || build main
|
[[ -f "$OUT/mnist_main" ]] || build mnist-main
|
||||||
[[ $1 ]] || set -- "train"
|
[[ $1 ]] || set -- "train"
|
||||||
[[ $2 == "-r" || $2 == "--recover" ]] && RECOVER="-r .cache/reseau.bin"
|
[[ $2 == "-r" || $2 == "--recover" ]] && RECOVER="-r .cache/reseau.bin"
|
||||||
mkdir -p .cache
|
mkdir -p .cache
|
||||||
"$OUT/main" train \
|
"$OUT/mnist_main" train \
|
||||||
--images "data/mnist/$1-images-idx3-ubyte" \
|
--images "data/mnist/$1-images-idx3-ubyte" \
|
||||||
--labels "data/mnist/$1-labels-idx1-ubyte" \
|
--labels "data/mnist/$1-labels-idx1-ubyte" \
|
||||||
--out ".cache/reseau.bin" \
|
--out ".cache/reseau.bin" \
|
||||||
@ -108,10 +122,10 @@ train () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
test_reseau () {
|
test_reseau () {
|
||||||
[[ -f "$OUT/main" ]] || build main
|
[[ -f "$OUT/mnist_main" ]] || build mnist-main
|
||||||
[[ $1 ]] || set -- "train"
|
[[ $1 ]] || set -- "train"
|
||||||
[[ -f ".cache/reseau.bin" ]] || train train
|
[[ -f ".cache/reseau.bin" ]] || train train
|
||||||
"$OUT/main" test \
|
"$OUT/mnist_main" test \
|
||||||
--images "data/mnist/$1-images-idx3-ubyte" \
|
--images "data/mnist/$1-images-idx3-ubyte" \
|
||||||
--labels "data/mnist/$1-labels-idx1-ubyte" \
|
--labels "data/mnist/$1-labels-idx1-ubyte" \
|
||||||
--modele ".cache/reseau.bin"
|
--modele ".cache/reseau.bin"
|
||||||
@ -121,9 +135,9 @@ test_reseau () {
|
|||||||
recognize () {
|
recognize () {
|
||||||
if [[ $1 ]]; then
|
if [[ $1 ]]; then
|
||||||
[[ $2 ]] || set -- "$2" "text"
|
[[ $2 ]] || set -- "$2" "text"
|
||||||
[[ -f "$OUT/main" ]] || build main
|
[[ -f "$OUT/mnist_main" ]] || build mnist-main
|
||||||
[[ -f ".cache/reseau.bin" ]] || train train
|
[[ -f ".cache/reseau.bin" ]] || train train
|
||||||
"$OUT/main" recognize \
|
"$OUT/mnist_main" recognize \
|
||||||
--modele ".cache/reseau.bin" \
|
--modele ".cache/reseau.bin" \
|
||||||
--in "$1" \
|
--in "$1" \
|
||||||
--out "$2"
|
--out "$2"
|
||||||
@ -135,13 +149,13 @@ recognize () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
utils () {
|
utils () {
|
||||||
[[ -f "$OUT/utils" ]] || build utils
|
[[ -f "$OUT/mnist_utils" ]] || build mnist-utils
|
||||||
"$OUT/utils" ${*:1}
|
"$OUT/mnist_utils" ${*:1}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
webserver () {
|
webserver () {
|
||||||
[[ -f "$OUT/main" ]] || build main
|
[[ -f "$OUT/mnist_main" ]] || build mnist-main
|
||||||
[[ -f ".cache/reseau.bin" ]] || train train
|
[[ -f ".cache/reseau.bin" ]] || train train
|
||||||
FLASK_APP="src/webserver/app.py" flask run
|
FLASK_APP="src/webserver/app.py" flask run
|
||||||
return 0
|
return 0
|
||||||
@ -149,7 +163,13 @@ webserver () {
|
|||||||
|
|
||||||
usage () {
|
usage () {
|
||||||
echo "Usage:"
|
echo "Usage:"
|
||||||
echo -e "\t$0 build ( main | preview | train | utils | all )\n"
|
echo -e "\t$0 build ( test | all | ... )"
|
||||||
|
echo -e "\t\t\tmnist: mnist"
|
||||||
|
echo -e "\t\t\t\tmnist-main"
|
||||||
|
echo -e "\t\t\t\tmnist-preview"
|
||||||
|
echo -e "\t\t\t\tmnist-utils"
|
||||||
|
echo -e "\t\t\tcnn: cnn"
|
||||||
|
echo -e "\t\t\t\tcnn-main\n"
|
||||||
echo -e "\t$0 train ( train | t10k ) ( -r | --recover )"
|
echo -e "\t$0 train ( train | t10k ) ( -r | --recover )"
|
||||||
echo -e "\t$0 preview ( train | t10k )"
|
echo -e "\t$0 preview ( train | t10k )"
|
||||||
echo -e "\t$0 test_reseau ( train | t10k )\n"
|
echo -e "\t$0 test_reseau ( train | t10k )\n"
|
||||||
|
@ -27,11 +27,11 @@ training = Training(BATCHS, DATASET, TEST_SET, CACHE)
|
|||||||
os.makedirs(CACHE, exist_ok=True)
|
os.makedirs(CACHE, exist_ok=True)
|
||||||
# On crée un réseau aléatoire si il n'existe pas encore
|
# On crée un réseau aléatoire si il n'existe pas encore
|
||||||
if not os.path.isfile(RESEAU):
|
if not os.path.isfile(RESEAU):
|
||||||
if not os.path.isfile("out/main"):
|
if not os.path.isfile("out/mnist_main"):
|
||||||
subprocess.call(["./make.sh", "build", "main"])
|
subprocess.call(["./make.sh", "build", "mnist-main"])
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
[
|
[
|
||||||
"out/main", "train",
|
"out/mnist_main", "train",
|
||||||
"--epochs", "0",
|
"--epochs", "0",
|
||||||
"--images", "data/mnist/train-images-idx3-ubyte",
|
"--images", "data/mnist/train-images-idx3-ubyte",
|
||||||
"--labels", "data/mnist/train-labels-idx1-ubyte",
|
"--labels", "data/mnist/train-labels-idx1-ubyte",
|
||||||
|
@ -118,13 +118,13 @@ def train_shared(dataset, start, nb_elem, epochs=1, out=DELTA):
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
# On compile out/main si il n'existe pas encore
|
# On compile out/main si il n'existe pas encore
|
||||||
if not os.path.isfile("out/main"):
|
if not os.path.isfile("out/mnist_main"):
|
||||||
subprocess.call(["./make.sh", "build", "main"])
|
subprocess.call(["./make.sh", "build", "mnist-main"])
|
||||||
|
|
||||||
# Entraînement du réseau
|
# Entraînement du réseau
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
[
|
[
|
||||||
"out/main", "train",
|
"out/mnist-main", "train",
|
||||||
"--epochs", str(epochs),
|
"--epochs", str(epochs),
|
||||||
"--images", images,
|
"--images", images,
|
||||||
"--labels", labels,
|
"--labels", labels,
|
||||||
|
@ -95,12 +95,12 @@ class Training:
|
|||||||
return
|
return
|
||||||
|
|
||||||
self.lock_test = True
|
self.lock_test = True
|
||||||
if not os.path.isfile("out/main"):
|
if not os.path.isfile("out/mnist_main"):
|
||||||
subprocess.call(["./make.sh", "build", "main"])
|
subprocess.call(["./make.sh", "build", "mnist-main"])
|
||||||
|
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
[
|
[
|
||||||
"out/main", "test",
|
"out/mnist_main", "test",
|
||||||
"--images", self.test_images,
|
"--images", self.test_images,
|
||||||
"--labels", self.test_labels,
|
"--labels", self.test_labels,
|
||||||
"--modele", self.reseau
|
"--modele", self.reseau
|
||||||
@ -127,11 +127,11 @@ class Training:
|
|||||||
with open(self.reseau + ".lock", "w", encoding="utf8") as file:
|
with open(self.reseau + ".lock", "w", encoding="utf8") as file:
|
||||||
file.write("")
|
file.write("")
|
||||||
|
|
||||||
if not os.path.isfile("out/utils"):
|
if not os.path.isfile("out/mnist_utils"):
|
||||||
subprocess.call(["./make.sh", "build", "utils"])
|
subprocess.call(["./make.sh", "build", "mnist-utils"])
|
||||||
subprocess.call(
|
subprocess.call(
|
||||||
[
|
[
|
||||||
"out/utils", "patch-network",
|
"out/mnist_utils", "patch-network",
|
||||||
"--network", self.reseau,
|
"--network", self.reseau,
|
||||||
"--delta", self.delta,
|
"--delta", self.delta,
|
||||||
])
|
])
|
||||||
|
@ -38,7 +38,7 @@ def recognize_mnist(image):
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
output = subprocess.check_output([
|
output = subprocess.check_output([
|
||||||
'out/main',
|
'out/mnist_main',
|
||||||
'recognize',
|
'recognize',
|
||||||
'--modele', '.cache/reseau.bin',
|
'--modele', '.cache/reseau.bin',
|
||||||
'--in', '.cache/image-idx3-ubyte',
|
'--in', '.cache/image-idx3-ubyte',
|
||||||
|
@ -8,22 +8,15 @@
|
|||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
printf("Création du réseau\n");
|
printf("Création du réseau\n");
|
||||||
|
|
||||||
Network* network = (Network*)malloc(sizeof(Network));
|
Network* network = (Network*)malloc(sizeof(Network));
|
||||||
int tab[5] = {30, 25, 20, 15, 10};
|
int tab[5] = {30, 25, 20, 15, 10};
|
||||||
network_creation(network, tab, 5);
|
network_creation(network, tab, 5);
|
||||||
|
|
||||||
printf("OK\n");
|
printf("OK\n");
|
||||||
|
|
||||||
printf("Initialisation du réseau\n");
|
printf("Initialisation du réseau\n");
|
||||||
|
|
||||||
network_initialisation(network);
|
network_initialisation(network);
|
||||||
|
|
||||||
printf("OK\n");
|
printf("OK\n");
|
||||||
printf("Enregistrement du réseau\n");
|
|
||||||
|
|
||||||
write_network(".test-cache/random_network.bin", network);
|
|
||||||
|
|
||||||
printf("OK\n");
|
|
||||||
deletion_of_network(network);
|
deletion_of_network(network);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -71,7 +71,11 @@ int main() {
|
|||||||
printf("Vérification de l'accès en lecture\n");
|
printf("Vérification de l'accès en lecture\n");
|
||||||
Network* network2 = read_network(".test-cache/neuron_io.bin");
|
Network* network2 = read_network(".test-cache/neuron_io.bin");
|
||||||
printf("OK\n");
|
printf("OK\n");
|
||||||
|
|
||||||
|
printf("Suppression des réseaux\n");
|
||||||
deletion_of_network(network);
|
deletion_of_network(network);
|
||||||
deletion_of_network(network2);
|
deletion_of_network(network2);
|
||||||
|
printf("OK\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
22
test/mnist_utils.sh
Executable file
22
test/mnist_utils.sh
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
OUT="$1"
|
||||||
|
[[ -f "$OUT/mnist_utils" ]] || "$2" build mnist-utils
|
||||||
|
|
||||||
|
echo "Compte des labels"
|
||||||
|
"$OUT/mnist_utils" count-labels -l data/mnist/t10k-labels-idx1-ubyte > /dev/null
|
||||||
|
echo "OK"
|
||||||
|
|
||||||
|
echo "Création du réseau"
|
||||||
|
"$OUT/mnist_utils" creer-reseau -n 3 -o .test-cache/reseau.bin > /dev/null
|
||||||
|
echo "OK"
|
||||||
|
|
||||||
|
echo "Affichage poids"
|
||||||
|
"$OUT/mnist_utils" print-poids -r .test-cache/reseau.bin > /dev/null
|
||||||
|
echo "OK"
|
||||||
|
|
||||||
|
echo "Affichage biais"
|
||||||
|
"$OUT/mnist_utils" print-biais -r .test-cache/reseau.bin > /dev/null
|
||||||
|
echo "OK"
|
@ -1,22 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
OUT="$1"
|
|
||||||
[[ -f "$OUT/utils" ]] || "$2" build utils
|
|
||||||
|
|
||||||
echo "Compte des labels"
|
|
||||||
"$OUT/utils" count-labels -l data/mnist/t10k-labels-idx1-ubyte > /dev/null
|
|
||||||
echo "OK"
|
|
||||||
|
|
||||||
echo "Création du réseau"
|
|
||||||
"$OUT/utils" creer-reseau -n 3 -o .test-cache/reseau.bin > /dev/null
|
|
||||||
echo "OK"
|
|
||||||
|
|
||||||
echo "Affichage poids"
|
|
||||||
"$OUT/utils" print-poids -r .test-cache/reseau.bin > /dev/null
|
|
||||||
echo "OK"
|
|
||||||
|
|
||||||
echo "Affichage biais"
|
|
||||||
"$OUT/utils" print-biais -r .test-cache/reseau.bin > /dev/null
|
|
||||||
echo "OK"
|
|
Loading…
Reference in New Issue
Block a user