|
|
|
|
@ -218,6 +218,11 @@ scores = model_1h500.evaluate(X_test, y_test)
|
|
|
|
|
print('Loss on test data:', scores[0])
|
|
|
|
|
print('Accuracy on test data:', scores[1])
|
|
|
|
|
```
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
Loss on test data: 0.24226699769496918
|
|
|
|
|
Accuracy on test data: 0.9291999936103821
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Наилучшую метрику наблюдаем при архитектуре со 100 нейронами в скрытом слое.
|
|
|
|
|
|
|
|
|
|
@ -257,6 +262,11 @@ print('Loss on test data:', scores[0])
|
|
|
|
|
print('Accuracy on test data:', scores[1])
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
Loss on test data: 0.19637857377529144
|
|
|
|
|
Accuracy on test data: 0.9409000277519226
|
|
|
|
|
|
|
|
|
|
При 100 нейронах
|
|
|
|
|
```python
|
|
|
|
|
# создаем модель
|
|
|
|
|
@ -289,6 +299,11 @@ print('Loss on test data:', scores[0])
|
|
|
|
|
print('Accuracy on test data:', scores[1])
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
Loss on test data: 0.19593027234077454
|
|
|
|
|
Accuracy on test data: 0.9416999816894531
|
|
|
|
|
|
|
|
|
|
### Пункт 10
|
|
|
|
|
Результаты исследования архитектуры нейронной сети занесли в таблицу
|
|
|
|
|
### Таблица с результатами тестирования нейросетевых моделей
|
|
|
|
|
@ -324,6 +339,11 @@ print('Real mark: ', str(np.argmax(y_test[n])))
|
|
|
|
|
print('NN answer: ', str(np.argmax(result)))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
Real mark: 0
|
|
|
|
|
NN answer: 0
|
|
|
|
|
|
|
|
|
|
### Пункт 13
|
|
|
|
|
Создали собственные изображения чисел
|
|
|
|
|
```python
|
|
|
|
|
@ -337,7 +357,13 @@ test_img = np.array(file_data)
|
|
|
|
|
# вывод собственного изображения
|
|
|
|
|
plt.imshow(test_img, cmap=plt.get_cmap('gray'))
|
|
|
|
|
plt.show()
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
# предобработка
|
|
|
|
|
test_img = test_img / 255
|
|
|
|
|
test_img = test_img.reshape(1, num_pixels)
|
|
|
|
|
@ -346,6 +372,9 @@ result = model_1h100_2h100.predict(test_img)
|
|
|
|
|
print('I think it\'s ', np.argmax(result))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
I think it's 5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
### Пункт 14
|
|
|
|
|
Создали копию нарисованных чисел и повернем их на 90 градусов. Протестируем работу нейронной сети.
|
|
|
|
|
```python
|
|
|
|
|
@ -363,7 +392,13 @@ test_img = test_img.reshape(1, num_pixels)
|
|
|
|
|
# распознавание
|
|
|
|
|
result = model_1h100_2h100.predict(test_img)
|
|
|
|
|
print('I think it\'s ', np.argmax(result))
|
|
|
|
|
```
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
I think it's 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```python
|
|
|
|
|
file_data = Image.open('five_v3_rotated.png')
|
|
|
|
|
file_data = file_data.convert('L') # перевод в градации серого
|
|
|
|
|
test_img = np.array(file_data)
|
|
|
|
|
@ -379,5 +414,10 @@ result = model_1h100_2h100.predict(test_img)
|
|
|
|
|
print('I think it\'s ', np.argmax(result))
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
|
|
|
I think it's 2
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Нейросеть некорректно определила повернутые изображения.
|