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

คูณเมทริกซ์ด้วย matmul และ @

ผลคูณจุดที่อยู่เบื้องหลังทุกชั้น

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

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

Beyond Elementwise

Multiplying tensors with the star sign is elementwise. Matrix multiplication is different: it mixes rows and columns into weighted sums.

Dot Products in Bulk

Each output entry of a matrix multiply is a dot product: one row of the left matrix paired with one column of the right matrix.

The Inner Dimensions Must Match

To multiply shapes (m, k) and (k, n), the inner k must agree. The result is (m, n): outer dimensions survive, the inner one is summed away.

The @ Operator

Python gives matrix multiply its own clean symbol. The @ operator multiplies two tensors the matrix way, no loops in sight.

c = a @ b

torch.matmul Does the Same

torch.matmul is the spelled-out twin of @. Same result, handy when you prefer a named function call in your code.

c = torch.matmul(a, b)

Mind the Shapes

A (2, 3) times a (3, 4) gives a (2, 4). Read the shapes left to right and the inner 3 cancels, leaving the outer pair.

a = torch.randn(2, 3)
b = torch.randn(3, 4)
c = a @ b  # shape (2, 4)

Star Is Not At

Do not confuse them: a * b is elementwise and needs matching shapes, while a @ b is matrix multiply and needs matching inner dimensions.

Matrix Times Vector

Multiply a matrix by a 1D vector and you get a vector. Each output number is the dot product of a matrix row with that vector.

y = W @ x  # W is (n, m), x is (m,), y is (n,)

Batched matmul

matmul handles batches: feed shapes (B, m, k) and (B, k, n) and it multiplies each of the B matrix pairs at once, returning (B, m, n).

out = torch.matmul(batch_a, batch_b)

Shape Errors Are Loud

Mismatch the inner dimensions and PyTorch throws a clear RuntimeError. Reading those shape messages quickly becomes your fastest debugging tool.

The Engine of Every Layer

This one operation is everywhere. A linear layer is just inputs times a weight matrix plus a bias, and matmul does that heavy lifting.

out = x @ W.T + bias

Quick Check

Time to check your shape arithmetic.

Recap: Rows Meet Columns

Matrix multiply with @ or torch.matmul pairs rows with columns into dot products; inner dimensions must match, outer ones survive. It powers every layer. 🔗

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

บทเรียน “คูณเมทริกซ์ด้วย matmul และ @” ฟรีหรือไม่

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

คุณจะเรียนรู้อะไรในบทเรียน “คูณเมทริกซ์ด้วย matmul และ @”

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

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

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

บทเรียน “คูณเมทริกซ์ด้วย matmul และ @” ใช้เวลานานแค่ไหน

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

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

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

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

  1. เหตุใดการวนซ้ำจึงช้าเมื่อคำนวณคณิตศาสตร์
  2. การดำเนินการทีละสมาชิกและการลดรูป
  3. คูณเมทริกซ์ด้วย matmul และ @
  4. ผลคูณจุดขับเคลื่อนทุกชั้น
← กลับไปที่ Deep Learning Academy