แบ่งชุดฝึก ชุดตรวจสอบ และชุดทดสอบ
เหตุใดจึงต้องมีสามชุด ไม่ใช่ชุดเดียว
แบ่งชุดฝึก ชุดตรวจสอบ และชุดทดสอบ เป็นบทเรียน Deep Learning Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Deep Learning Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Deep Learning Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
One Pile Is Not Enough
If you train and judge a model on the same data, you only learn that it memorized those rows. To trust it, you must split your data into separate roles.
Meet the Training Set
The training set is the data your model actually learns from. Its weights are nudged again and again to fit exactly these examples well.
Meet the Validation Set
The validation set is held back during training and checked along the way. It tells you how the model does on data it has never updated on.
Meet the Test Set
The test set is touched once, at the very end. It gives an honest, final score after every choice has already been made.
Why Validation Is Separate
You tune knobs like learning rate by watching validation results. That quietly leaks the validation set into your choices, so it can no longer be a clean final judge.
The Test Set Stays Sealed
Because validation guided your decisions, you need one untouched pile for the truth. Keep the test set sealed until you are completely done.
A Common Split
A typical starting point is roughly 80/10/10: most data for training, smaller slices for validation and test. Adjust based on how much data you have.
Split with random_split
PyTorch gives you random_split to carve a dataset into pieces by length. It shuffles which samples land in each set for you.
from torch.utils.data import random_split
train, val, test = random_split(ds, [800, 100, 100])Seed for Reproducible Splits
The split is random, so set a seed if you want the same pieces every run. That keeps experiments comparable across sessions.
g = torch.Generator().manual_seed(42)
train, val, test = random_split(ds, [800, 100, 100], generator=g)Stratify for Balance
With rare classes, a plain random split may leave some out. Stratifying keeps each set's class mix close to the original so scores stay meaningful.
Never Peek at Test
The golden rule is simple: do not let the test set shape any decision. The moment it does, your final number stops being trustworthy.
Quick Check
Which set should you look at only once, at the very end?
Recap
Three sets, three jobs: training teaches the model, validation guides your tuning, and test gives the final honest score. Keep test sealed until the end. 🎯
คำถามที่พบบ่อย
บทเรียน “แบ่งชุดฝึก ชุดตรวจสอบ และชุดทดสอบ” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “แบ่งชุดฝึก ชุดตรวจสอบ และชุดทดสอบ” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Deep Learning Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Deep Learning Academy มีบทเรียนทั้งหมด 4 บทเรียน
คุณจะเรียนรู้อะไรในบทเรียน “แบ่งชุดฝึก ชุดตรวจสอบ และชุดทดสอบ”
เหตุใดจึงต้องมีสามชุด ไม่ใช่ชุดเดียว คุณปฏิบัติ Deep Learning Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน
คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Deep Learning Academy หรือไม่
ไม่จำเป็นต้องมีประสบการณ์มาก่อน Deep Learning Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 1 จากทั้งหมด 4 บทเรียน
บทเรียน “แบ่งชุดฝึก ชุดตรวจสอบ และชุดทดสอบ” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Deep Learning Academy นี้ได้ไหม
ได้ บทเรียน Deep Learning Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- แบ่งชุดฝึก ชุดตรวจสอบ และชุดทดสอบ
- วงรอบยุคพร้อมการตรวจสอบ
- บันทึกและโหลดด้วย state_dict
- หยุดก่อนกำหนดเมื่อค่าความสูญเสียชุดตรวจสอบเพิ่มขึ้น