Basic of Deep learning #4

갱갱·2024년 12월 22일

ZB_DeepLearning

목록 보기
5/12
post-thumbnail

2024.12.22
1. CNN : Convolution 레이어, 필터 관련 내용


CNN

CNN은 사진에서 특징검출하는 기능을 가진 레이가 있다. 특징을 검출한다는 것이 중요하다.
Convolution 필터 : 특정 패턴이 있는지 박스로 훓으며 마킹.

실습 - 데이터 읽기



모델생성



학습 및 컴파일

  • Accuracy가 거의 99% 이상 높게 나온다.
    Google의 Colabs에서도 GPU를 이용해서 학습할 수 있다


잘못된 결과 확인

import numpy as np
import random

predicted_result = model.predict(X_test)
predicted_label = np.argmax(predicted_result, axis=1)

wrong_result = []


for n in range(0, len(y_test)):
    if predicted_label[n] != y_test[n]:
        wrong_result.append(n)

samples = random.choices(population=wrong_result, k=16)

plt.figure(figsize=(14,12))

for idx, n in enumerate(samples):
    plt.subplot(4,4,idx+1)
    plt.imshow(X_test[n].reshape(28, 28), cmap='Greys')
    plt.title('Label : ' + str(y_test[n]) + '  | predicted : ' + str(predicted_label[n]))
    plt.axis('off')
plt.show()



모델의 저장


model.save('MNIST_CNN_model.h5')
profile
(hellow. world)

0개의 댓글