Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

การ Preprocess ข้อมูล Fashion MNIST ด้วย TensorFlow


บทนำ

TensorFlow เฟรมเวิร์ก ML จาก Google โค้ดเปิด ใช้กับ Python ใช้ในงานวิจัยและการผลิต

การติดตั้ง

pip install tensorflow

Tensor และชุดข้อมูล Fashion MNIST

เทนเซอร์ = อาร์เรย์หลายมิติ สำหรับ Data flow graph Fashion MNIST: ภาพเสื้อผ้า 70,000+ ภาพ 10 หมวดหมู่ 28x28 pixels

ตัวอย่าง: ตรวจสอบภาพ และ Normalize

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

ที่มาโค้ด: TensorFlow Classification Tutorial

ผลลัพธ์

การ Preprocess ข้อมูล Fashion MNIST ด้วย TensorFlow

การ Preprocess ข้อมูล Fashion MNIST ด้วย TensorFlow

คำอธิบาย

  • ก่อนฝึก ต้อง preprocess ข้อมูลอินพุต
  • ตรวจสอบภาพ พบค่า pixel 0-255
  • Scale ให้อยู่ในช่วง 0-1 โดยหาร 255
  • Train และ Test ต้อง preprocess แบบเดียวกัน
  • แสดงภาพตัวอย่างพร้อมชื่อคลาส เพื่อยืนยันรูปแบบข้อมูล