0Pricing
Deep Learning Academy · บทเรียน

Sigmoid และ Tanh: บีบค่าให้อยู่ในช่วง

เอาต์พุตที่มีขอบเขตและกับดักเกรเดียนต์หาย

Sigmoid และ Tanh: บีบค่าให้อยู่ในช่วง เป็นบทเรียน Deep Learning Academy ฟรีบน CoddyKit นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน คุณสามารถอ่านบทเรียนทั้งหมดด้านล่างฟรี — จากนั้นลองปฏิบัติด้วยตัวคุณเองในเบราว์เซอร์พร้อมตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7 บทเรียนนี้เป็นส่วนหนึ่งของเส้นทางการเรียน Deep Learning Academy และความก้าวหน้าของคุณจะซิงค์ข้ามเว็บและแอป CoddyKit คอร์ส Deep Learning Academy มีบทเรียนทั้งหมด 4 บทเรียน

บางส่วนของบทเรียนนี้ยังไม่ได้รับการแปล และแสดงเป็นภาษาอังกฤษ

Squashing Activations

Some activations squeeze any input into a fixed range. The two classics are sigmoid and tanh, and both bend big numbers gently inward. 🤏

Sigmoid's Range

Sigmoid maps every value into the open interval from 0 to 1. That makes its output read naturally as a probability.

import torch
y = torch.sigmoid(x)   # outputs between 0 and 1

Its S-Shaped Curve

Sigmoid has a smooth S shape: near zero it changes fast, but far out it flattens. Large inputs all map to nearly the same value.

Tanh's Range

Tanh is sigmoid's cousin, but it squashes inputs into the range from minus 1 to plus 1, centered neatly on zero.

y = torch.tanh(x)   # outputs between -1 and 1

Why Centering Helps

Because tanh is zero-centered, its outputs balance around zero. That often gives smoother, faster learning than sigmoid for hidden layers.

The Flat Tails

Out at the edges, both curves go almost flat. A flat region means a tiny slope, and a tiny slope means a tiny gradient.

Vanishing Gradients

When gradients shrink toward zero, early layers barely update. This vanishing gradient trap stalls deep networks during training. 😴

Why ReLU Took Over

This vanishing problem is exactly why ReLU replaced sigmoid and tanh in most hidden layers. ReLU keeps a healthy gradient for positives.

Where Sigmoid Still Wins

Sigmoid stays useful at the output of a binary classifier, where you genuinely want a single probability between 0 and 1.

Where Tanh Still Wins

Tanh still appears inside recurrent cells like LSTMs, where its bounded, zero-centered output helps keep the hidden state stable.

Choosing Wisely

Rule of thumb: avoid sigmoid and tanh in deep hidden stacks, but keep sigmoid for a single probability output. Match the tool to the job.

Quick Check

Recall what happens at the flat tails of these curves.

Recap

Sigmoid squashes to 0 to 1 and tanh to minus 1 to 1. Their flat tails cause vanishing gradients, so save them for outputs and special cells. 🎯

คำถามที่พบบ่อย

บทเรียน “Sigmoid และ Tanh: บีบค่าให้อยู่ในช่วง” ฟรีหรือไม่

ใช่ — ข้อความเต็มของ “Sigmoid และ Tanh: บีบค่าให้อยู่ในช่วง” ฟรีให้อ่านที่นี่บนเว็บ เพื่อปฏิบัติแบบโต้ตอบ (ตัวแก้ไขโค้ดในตัวและติวเตอร์ AI ตลอด 24/7) และปลดล็อคส่วนที่เหลือของคอร์ส Deep Learning Academy ให้อัปเกรดเป็น CoddyKit PRO คอร์ส Deep Learning Academy มีบทเรียนทั้งหมด 4 บทเรียน

คุณจะเรียนรู้อะไรในบทเรียน “Sigmoid และ Tanh: บีบค่าให้อยู่ในช่วง”

เอาต์พุตที่มีขอบเขตและกับดักเกรเดียนต์หาย คุณปฏิบัติ Deep Learning Academy ด้วยโค้ดที่ใช้งานได้จริงที่คุณเรียกใช้โดยตรงในเบราว์เซอร์ และติวเตอร์ AI ตลอด 24/7 ตอบคำถามของคุณขณะที่คุณไปผ่านบทเรียน

คุณต้องมีประสบการณ์ก่อนที่จะเริ่มเรียน Deep Learning Academy หรือไม่

ไม่จำเป็นต้องมีประสบการณ์มาก่อน Deep Learning Academy บน CoddyKit ออกแบบมาสำหรับผู้เริ่มต้นไปจนถึงผู้เรียนขั้นสูง คุณสามารถเริ่มต้นที่นี่หรือเริ่มจากตัวแรกและเรียนด้วยความเร็วของคุณเอง นี่คือบทเรียนที่ 3 จากทั้งหมด 4 บทเรียน

บทเรียน “Sigmoid และ Tanh: บีบค่าให้อยู่ในช่วง” ใช้เวลานานแค่ไหน

บทเรียน CoddyKit ส่วนใหญ่ใช้เวลาประมาณ 5–10 นาที แต่ละบทเรียนจึงสั้นและเป็นแบบโต้ตอบ คุณสามารถก้าวหน้าอย่างต่อเนื่องและกลับมาเรียนต่อจากตรงที่เพิ่งหยุดบนเว็บและแอปได้เลย

ฉันเขียนและรันโค้ดในบทเรียน Deep Learning Academy นี้ได้ไหม

ได้ บทเรียน Deep Learning Academy ทุกบทมีตัวแก้ไขโค้ดในตัว คุณจึงเขียนและรันโค้ดจริงได้เลยในเบราว์เซอร์ และได้รับข้อเสนอแนะจาก AI ในทันที — ไม่ต้องติดตั้งในเครื่องของคุณ

บทเรียนทั้งหมดในหลักสูตรนี้

  1. เหตุใดความไม่เป็นเชิงเส้นจึงปลดล็อกพลังที่แท้จริง
  2. ReLU และญาติอย่าง Leaky กับ GELU
  3. Sigmoid และ Tanh: บีบค่าให้อยู่ในช่วง
  4. Softmax สำหรับความน่าจะเป็น
← กลับไปที่ Deep Learning Academy