TensorFlow Playground คือ เว็บไซต์ที่ให้เราเรียนรู้เกี่ยวกับ Neural Network ด้วยการเป็นเครื่องมือให้เราได้ออกแบบ และเทรน Neural Network ที่มีขนาดเล็ก ไม่ซับซ้อนมาก แต่ทำงานได้จริง

TensorFlow Playground ใช้งานสะดวกเพราะไม่ต้องติดตั้งโปรแกรมอะไรเลย สามารถใช้งานผ่านเว็บไซต์ได้ทันที

1. Overview ภาพรวม

TensorFlow Playground Screenshot 10 Overview
TensorFlow Playground Screenshot 10 Overview

TensorFlow Playground จะมีโจทย์ให้เลือก 4 แบบ มีการแสดงผล Visualization การทำงานภายใน Neural Network / Output ที่เข้าใจง่าย ทำให้เหมาะกับใช้ในภาคการศึกษา ใช้สอน Neural Network สำหรับผู้เริ่มต้นเรียนรู้

โจทย์คือให้เราออกแบบ และเทรน Neural Network ให้สร้างพื้นที่เป็นสี ให้ตรงกับจุดสีในโจทย์

2. Sections ส่วนต่าง ๆ

TensorFlow Playground Screenshot 11 Parts
TensorFlow Playground Screenshot 11 Parts

TensorFlow Playground มีแค่ 1 หน้าจอเท่านั้น แบ่งเป็นส่วนต่าง ๆ ดังนี้

  • ด้านบน สีแดง เกี่ยวกับ Control ควบคุมการเทรน และ Hyperparameter
  • ด้านซ้าย สีน้ำเงิน เกี่ยวกับ ชุดข้อมูล Dataset, Train / Test Split
  • ตรงกลาง สีเหลือง เกี่ยวกับ โมเดล, Layer, Input Feature
  • ด้านขวา สีเขียว คือ Output ของโมเดล พล็อตเป็นรูปภาพแบ่งสี และ Loss ว่าโมเดลทำงานเป็นอย่างไร

3. Controls การควบคุม

TensorFlow Playground Screenshot 12 Reset Train Step Epoch Number
TensorFlow Playground Screenshot 12 Reset Train Step Epoch Number
  • Reset เริ่มเทรนใหม่ / Initialize Parameter ใหม่
  • Play เริ่มเทรนไปเรื่อย ๆ จนกว่าจะกดอีกครั้ง เป็น Pause
  • Step ค่อย ๆ เทรน 1 Epoch แล้วหยุดก่อน
  • Epoch Number จำนวน Epoch ที่โมเดลได้เทรนไปแล้ว

4. Hyperparameter

TensorFlow Playground Screenshot 13 Hyperparameter Tuning
TensorFlow Playground Screenshot 13 Hyperparameter Tuning

5. Data ข้อมูล

TensorFlow Playground Screenshot 14 Input Data, Ratio of Training Set Test Set, Noise, Batch Size
TensorFlow Playground Screenshot 14 Input Data, Ratio of Training Set Test Set, Noise, Batch Size
  • Data เลือกโจทย์ คือ Dataset ข้อมูลจุดสีน้ำเงิน (1) และจุดสีส้ม (-1) ที่จะเรียงตัว แบบโดนัทล้อมรอบ (ปานกลาง), แบบแยกทแยงมุม (ปานกลาง), แบบแยก 2 กอง (ง่าย), แบบ Spiral เกลียว (ยาก)
  • Ratio of training to test data คือ Train / Test Split
  • Noise คือ ข้อมูล Noise ที่ Random ปนเปื้อนอยู่ใน Dataset ทำให้ยากขึ้นนิดหน่อย
  • Batch Size คือ เราจะป้อนข้อมูลให้โมเดลทีละกี่ตัวอย่างพร้อมกัน
  • ปุ่ม Regenerate คือ ให้ระบบ Random สร้าง ชุดข้อมูลชุดใหม่ ขึ้นมาจาก Config ด้านบน

6. Feature

TensorFlow Playground Screenshot 15 Input Feature
TensorFlow Playground Screenshot 15 Input Feature
  • X1 คือ Feature แรก ที่เราจะพล็อตในแกน X
  • X2 คือ Feature ที่สอง ที่เราจะพล็อตในแกน Y
  • ที่เหลือคือ Feature Engineering ของ Feature X1 และ X2

หมายเหตุ ค่าของข้อมูล สีส้ม = -1, สีขาว = 0 และ สีน้ำเงิน = 1

7. Model / Hidden Layers

TensorFlow Playground Screenshot 16 Neural Network Model - Hidden Layers
TensorFlow Playground Screenshot 16 Neural Network Model – Hidden Layers

เราสามารถออกแบบ โมเดล Neural Network แบบง่าย ๆ ได้ดังนี้

  • Hidden Layer จำนวน 0 – 6 Layer
  • Neuron ของแต่ละ Layer จำนวน 1-8 Neuron

TensorFlow Playground จะแสดง Visualization ของ Neuron และ Output ของ Neuron จะขึ้นอยู่กับ Weight ภายใน เราสามารถ คลิก ที่เส้นเพื่อดูค่า Weight และ Set ค่าใหม่ที่เราต้องการได้เอง

8. Output ผลลัพธ์ และ Loss

TensorFlow Playground Screenshot 17 Output Test Loss, Training Loss
TensorFlow Playground Screenshot 17 Output Test Loss, Training Loss

Output ของโมเดล นำมาทำ Visualization พล็อตเป็นกราฟ (พื้นที่ถมสี) เปรียบเทียบว่าตรงกับโจทย์ (จุดสี) แค่ไหน คำนวนเป็นค่า Test Loss และ Train Loss

นอกจากแสดง Output vs Training Data เราสามารถเลือกให้แสดงข้อมูล

  • Show test data แสดงข้อมูล Test Data ว่า Test Loss คำนวนมาจากตรงไหน
  • Discretize output แสดง Output เป็นค่าไม่ต่อเนื่อง หมายถึง -1 สีส้ม / 1 สีน้ำเงิน เลย จะได้เห็นชัด ๆ ไม่ต้องไล่เฉด

Usage การใช้งาน

Demonstrating activity-based learning in the classroom. Credit https://commons.wikimedia.org/wiki/File:Unterricht.jpg
Demonstrating activity-based learning in the classroom. Credit https://commons.wikimedia.org/wiki/File:Unterricht.jpg
  • แนะนำให้เริ่มต้นจากโจทย์ที่ง่ายที่สุดก่อน คือ Data แบบแยก 2 กอง (ง่าย) โดย ลบ Layer ออกให้หมด เริ่มต้นเทรน ตั้งแต่ 0 Layer
  • เมื่อได้ผลลัพธ์เป็นที่น่าพอใจ แล้วจึงขยับไปโจทย์ที่ยากปานกลาง ได้แก่ แบบโดนัทล้อมรอบ, แบบแยกทแยง แล้วค่อยเพิ่มจำนวน Layer และ Neuron, ปรับเปลี่ยน Hyperparameter, เพิ่ม Feature, etc.
  • สังเกตเปรียบเทียบ Output, Loss และจำนวน Epoch ที่ใช้เทรน
  • ศึกษาทำความเข้าใจ ความหมายของ ส่วนประกอบต่าง ๆ ของ Neural Network
  • อาจจะจัดแข่งกันใน Class โดยกำหนดข้อจำกัดว่า เทรนได้ไม่เกินกี่ Epoch, Test Loss ห้ามเกิน 0.05, Layer ไม่เกิน 3, ห้ามใช้ ReLU เป็นต้น

Credit

แชร์ให้เพื่อน:

Surapong Kanoktipsatharporn on FacebookSurapong Kanoktipsatharporn on LinkedinSurapong Kanoktipsatharporn on Rss
Surapong Kanoktipsatharporn
Solutions Architect at Bua Labs
The ultimate test of your knowledge is your capacity to convey it to another.

Published by Surapong Kanoktipsatharporn

The ultimate test of your knowledge is your capacity to convey it to another.