ปรับอินพุตให้เป็นมาตรฐาน
ปรับสเกลคุณลักษณะเพื่อให้การฝึกบรรจบกัน
ปรับอินพุตให้เป็นมาตรฐาน เป็นบทเรียน Deep Learning Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Deep Learning Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Deep Learning Academy มีบทเรียนทั้งหมด 4 บทเรียน
บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ
Raw Numbers Slow Learning
Features on wildly different scales, like age and salary, confuse a network. Rescaling them first is why normalization makes training converge faster. ⚖️
Two Common Recipes
You will meet two main scalers: standardization shifts data to mean zero and unit variance, while min-max squeezes it into a fixed range like 0 to 1.
Standardize with Mean and Std
Standardization subtracts the mean and divides by the standard deviation. The result is centered on zero with a spread of one, the deep learning default.
x = (x - x.mean()) / x.std()Min-Max Scaling
Min-max scaling maps your smallest value to 0 and largest to 1. It is handy when a bounded input range matters, like pixel intensities.
x = (x - x.min()) / (x.max() - x.min())Fit on Train Only
Compute the mean and std from the training set only. Reusing test data to set these stats leaks information and inflates your scores.
Reuse the Same Stats
Apply the exact training statistics to validation and test data. Both splits must be transformed the same way or your model sees mismatched inputs.
x_val = (x_val - train_mean) / train_stdPer-Channel for Images
For images you normalize each color channel with its own mean and std. PyTorch ships transforms.Normalize to do exactly this in a pipeline.
transforms.Normalize(mean=[0.5], std=[0.5])Borrow Known ImageNet Stats
When using pretrained vision models, normalize with the ImageNet means and stds they were trained on. Matching those numbers keeps inputs in the expected range.
Do It Inside __getitem__
The cleanest spot to scale is your dataset's __getitem__ or a transform. Then every sample arrives normalized without extra code in your training loop.
Watch for Divide by Zero
If a feature is constant its std is zero and dividing explodes. Add a tiny epsilon to the denominator to keep the math safe and stable.
x = (x - mean) / (std + 1e-8)Small Step, Big Payoff
Normalizing inputs is a quick preprocessing habit, yet it often unlocks faster, more stable training. Skip it and even a good model may crawl.
Quick Check
From which split should you compute normalization statistics?
Recap
Normalization rescales features so training converges, using stats fit on the training set and reused everywhere, often inside a transform. 🎉
คำถามที่พบบ่อย
บทเรียน “ปรับอินพุตให้เป็นมาตรฐาน” ฟรีหรือไม่
ใช่ — ข้อความเต็มของ “ปรับอินพุตให้เป็นมาตรฐาน” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ 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 ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 4 จากทั้งหมด 4 บทเรียน
บทเรียน “ปรับอินพุตให้เป็นมาตรฐาน” ใช้เวลานานแค่ไหน
บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย
ฉันเขียนและรันโค้ดในบทเรียน Deep Learning Academy นี้ได้ไหม
ได้ บทเรียน Deep Learning Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ
บทเรียนทั้งหมดในหลักสูตรนี้
- เขียนคลาสชุดข้อมูลแบบกำหนดเอง
- การจัดแบตช์ การสับเปลี่ยน และ num_workers
- collate_fn สำหรับอินพุตความยาวต่างกัน
- ปรับอินพุตให้เป็นมาตรฐาน