TensorFlow (Google) framework học máy mã nguồn mở. Cài đặt: pip install tensorflow. Tensor: mảng đa chiều.
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ụ
plt.figure()
plt.imshow(train_images[0])
plt.colorbar()
plt.grid(False)
plt.show()
train_images = train_images / 255.0
test_images = test_images / 255.0
plt.figure(figsize=(12,12))
for i in range(15):
plt.subplot(5,5,i+1)
plt.xticks([])
plt.yticks([])
plt.grid(False)
plt.imshow(train_images[i], cmap=plt.cm.binary)
plt.xlabel(class_names[train_labels[i]])
plt.show()
Nguồn mã: TensorFlow Classification Tutorial
Đầu ra


Giải thích
- Trước khi train, tiền xử lý dữ liệu đầu vào.
- Kiểm tra ảnh: giá trị pixel trong [0, 255].
- Chuẩn hóa pixel về [0, 1] bằng chia 255.
- Train set và test set phải tiền xử lý giống nhau.
- Đảm bảo định dạng đúng: hiển thị vài ảnh đầu kèm tên class.