-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIA_brut.py
71 lines (46 loc) · 1.54 KB
/
IA_brut.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#Initialisation(prend du temps)
import numpy as np
import numpy.random as random
from matplotlib import pyplot as plt
from os import getcwd, chdir
from keras.datasets import mnist
from keras import models
from keras import layers
chdir('C:\\Users\sacha\Desktop\TIPE\programmes utilisés')
from DataCreationIA import *
plt.imshow(Vecteurtrain[0], interpolation='nearest')
plt.show()
print(Vecteurlabeltrain[0])
plt.imshow(Vecteurtrain[1], interpolation='nearest')
plt.show()
print(Vecteurlabeltrain[1])
plt.imshow(Vecteurtest[0], interpolation='nearest')
plt.show()
print(Vecteurlabeltest[0])
## creation des layers
model = models.Sequential()
model.add(layers.Conv2D(32, (3, 3), activation='relu',
input_shape=(120, 180, 3)))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(64, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(128, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Conv2D(128, (3, 3), activation='relu'))
model.add(layers.MaxPooling2D((2, 2)))
model.add(layers.Flatten())
model.add(layers.Dense(512, activation='relu'))
model.add(layers.Dense(4, activation='softmax'))
model.compile(optimizer='rmsprop',
loss='categorical_crossentropy',
metrics=['accuracy'])
## Entrainenment de l'ia
model.fit(Vecteurtrain, Vecteurlabeltrain, epochs=10, batch_size=6)
##Test de l'ia
test_loss, test_acc = model.evaluate(Vecteurtest, Vecteurlabeltest)
print(test_acc)
"""
##
test_loss, test_acc = model.evaluate(Nutellatest, Nutellalabeltest)
print(test_acc)
"""