TensorFlow (Google) framework học máy mã nguồn mở. Cài đặt: pip install tensorflow.
Fashion MNIST: >70.000 ảnh grayscale trang phục 10 loại, 28x28 pixel.
Chạy trên Google Colab (Python trên trình duyệt, GPU miễn phí).
Ví dụ
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("Vẽ ảnh test, nhãn dự đoán và nhãn thật")
print("Dự đoán đúng: xanh lá, sai: đỏ")
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()
Nguồn mã: TensorFlow Classification Tutorial
Đầu ra



Giải thích
- Sau khi train, dùng mô hình dự đoán ảnh khác.
- Dự đoán trên 1 ảnh, hiển thị mảng xác suất.
- Nhãn đúng: màu xanh lá, nhãn sai: màu đỏ.
- Số phần trăm thể hiện độ tin cậy của nhãn dự đoán.
- Cho biết độ chính xác mô hình gán nhãn cho ảnh.