
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')