mirror of
https://github.com/augustin64/projet-tipe
synced 2025-01-23 23:26:25 +01:00
Update scripts
This commit is contained in:
parent
ac5c9c12c9
commit
f468883eb1
@ -70,8 +70,21 @@ def plot_temps_exec(data):
|
||||
GPUtime = [i["GPUtime"] for i in data]
|
||||
CPUtime = [i["CPUtime"] for i in data]
|
||||
|
||||
plt.plot(x, GPUtime)
|
||||
plt.plot(x, CPUtime)
|
||||
fig, ax = plt.subplots()
|
||||
|
||||
#ax.set_yscale("log")
|
||||
gputime, = ax.plot(x, GPUtime)
|
||||
cputime, = ax.plot(x, CPUtime)
|
||||
|
||||
gputime.set_label("Temps GPU")
|
||||
cputime.set_label("Temps CPU")
|
||||
|
||||
ax.set_ylabel("Temps d'exécution (secondes)")
|
||||
ax.set_xlabel("Taille de la matrice d'entrée")
|
||||
|
||||
ax.legend()
|
||||
|
||||
plt.grid(True)
|
||||
plt.show()
|
||||
|
||||
def plot_erreur(data):
|
||||
|
@ -28,7 +28,7 @@ def image_from_file(filepath, dest="./images/"):
|
||||
png.from_array(data[i], 'L').save(os.path.join(dest, f"{i}.png"))
|
||||
|
||||
|
||||
def image_from_list(filepath, dest="data.png", exp=False):
|
||||
def image_from_list(filepath, exp=False):
|
||||
"""
|
||||
Enregistre une liste de poids sous forme d'une image
|
||||
exp sert à spécifier si il faut passer à une forme exponentielle
|
||||
@ -54,13 +54,13 @@ def image_from_list(filepath, dest="data.png", exp=False):
|
||||
for j in range(IMAGE_HEIGHT):
|
||||
new_data[i][j] = data[i*IMAGE_HEIGHT+j]
|
||||
|
||||
png.from_array(new_data, 'L').save(dest)
|
||||
return new_data
|
||||
|
||||
|
||||
def graph_from_test_reseau(erreurs, reussites):
|
||||
"""
|
||||
Affiche un graphique à partir d'un fichier contenant les
|
||||
réussites et d'un autre contenant les erreurs (sortie brutes de out/main)
|
||||
réussites et d'un autre contenant les erreurs (sortie brutes de out/mnist_main)
|
||||
"""
|
||||
with open(erreurs, "r", encoding="utf8") as f:
|
||||
data = f.read()
|
||||
@ -113,7 +113,21 @@ def images_neurons(neurons, dest="neurons", exp=False):
|
||||
Afin de créer un ensemble d'image visualisant les poids
|
||||
"""
|
||||
os.makedirs(dest, exist_ok=True)
|
||||
data = []
|
||||
for i in neurons:
|
||||
os.system(f"./make.sh utils print-poids-neurone --reseau \
|
||||
.cache/reseau.bin --neurone {i} > .cache/poids.txt")
|
||||
image_from_list(".cache/poids.txt", os.path.join(dest, f"{i}.png"), exp=exp)
|
||||
data.append(image_from_list(".cache/poids.txt", exp=exp))
|
||||
|
||||
new_data = data.copy()
|
||||
|
||||
for i, _ in enumerate(new_data):
|
||||
for j, _ in enumerate(new_data[i]):
|
||||
for k, _ in enumerate(new_data[i][j]):
|
||||
for l, _ in enumerate(new_data):
|
||||
if i != l:
|
||||
new_data[i][j][k] -= data[l][j][k] * 0.11
|
||||
new_data[i][j][k] = max(int(new_data[i][j][k]), 0)
|
||||
|
||||
for i in neurons:
|
||||
png.from_array(data[i], 'L').save(os.path.join(dest, f"{i}.png"))
|
||||
|
Loading…
Reference in New Issue
Block a user