Files
agila-learning-examples/en/expanded-25-1/lesson-2/lesson.html
T

6 lines
1.5 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html><html lang="en"><meta charset="utf-8"><title>Shapes before matrix multiplication</title><h1>Shapes before matrix multiplication</h1><p>15-minute session: read for 3 minutes, trace for 3, experiment for 7, and complete the check for 2. Spend longer whenever you need.</p><p>For A with shape m×k and B with shape k×n, the result has shape m×n. The inner dimensions must match. Check empty and ragged inputs before indexing. A shape check prevents some errors but cannot establish that the weights mean the right thing. The example is a small CPU reference, not a trained language model.</p><p><strong>Practice and evidence:</strong> Predict the example or draw its state transitions. Change one assumption, test the boundary, and record the actual result. Explain what this small model does not establish about a production system.</p><pre><code class="language-python">a=[[1,2],[3,4]]
b=[[5],[6]]
assert all(len(row)==len(b) for row in a)
out=[[sum(a[i][k]*b[k][j] for k in range(len(b))) for j in range(len(b[0]))] for i in range(len(a))]
print(out)
</code></pre><p><strong>Expected result:</strong> <code>[[17], [39]]</code></p><h3>Practice and evidence</h3><p>Keep three notes: your prediction, the actual result, and why they match or differ. The completion check grades understanding; the practice task builds skill.</p><p><a href="https://git.agilaos.com/matt/open_agx">Language reference: git.agilaos.com</a></p><p><a href="https://onnx.ai/onnx/intro/">Language reference: onnx.ai</a></p></html>