Tensorflow는 Google에서 제공하는 기계 학습 프레임워크입니다. 알고리즘, 딥 러닝 애플리케이션 등을 구현하기 위해 Python과 함께 사용되는 오픈 소스 프레임워크입니다. 연구 및 생산 목적으로 사용됩니다.
'tensorflow' 패키지는 아래 코드 줄을 사용하여 Windows에 설치할 수 있습니다. -
pip install tensorflow
'Fashion MNIST' 데이터셋에는 다양한 종류의 의복 이미지가 포함되어 있습니다. 10가지 카테고리에 속하는 70,000개 이상의 옷에 대한 회색조 이미지가 포함되어 있습니다. 이 이미지는 저해상도(28 x 28픽셀)입니다.
Google Colaboratory를 사용하여 아래 코드를 실행하고 있습니다. Google Colab 또는 Colaboratory는 브라우저를 통해 Python 코드를 실행하는 데 도움이 되며 구성이 필요 없고 GPU(그래픽 처리 장치)에 대한 무료 액세스가 필요합니다. Colaboratory는 Jupyter Notebook을 기반으로 구축되었습니다.
다음은 Python에서 Fashion MNIST에 대한 예측을 확인하는 코드 스니펫입니다.
예시
i = 0
plt.figure(figsize=(6,3))
plt.subplot(1,2,1)
plot_image(i, predictions[i], test_labels, test_images)
plt.subplot(1,2,2)
plot_value_array(i, predictions[i], test_labels)
plt.show()
i = 12
plt.figure(figsize=(6,3))
plt.subplot(1,2,1)
plot_image(i, predictions[i], test_labels, test_images)
plt.subplot(1,2,2)
plot_value_array(i, predictions[i], test_labels)
plt.show()
num_rows = 5
num_cols = 3
print("The test images, predicted labels and the true labels are plotted")
print("The correct predictions are in green and the incorrect predictions are in red")
num_images = num_rows*num_cols
plt.figure(figsize=(2*2*num_cols, 2*num_rows))
for i in range(num_images):
plt.subplot(num_rows, 2*num_cols, 2*i+1)
plot_image(i, predictions[i], test_labels, test_images)
plt.subplot(num_rows, 2*num_cols, 2*i+2)
plot_value_array(i, predictions[i], test_labels)
plt.tight_layout()
plt.show() 코드 크레딧 - https://www.tensorflow.org/tutorials/keras/classification
출력



설명
-
모델이 학습되면 다른 이미지를 예측하는 데 사용할 수 있습니다.
-
이미지에 예측이 이루어지고 예측 배열이 표시됩니다.
-
올바르게 예측된 레이블은 녹색으로, 잘못 예측된 레이블은 빨간색으로 표시됩니다.
-
숫자는 예측된 레이블의 백분율 값을 나타냅니다.
-
모델이 예측한 레이블이 이미지의 실제 레이블임을 얼마나 정확하게 제안하는지 알려줍니다.