LESSON 46 OF 52 · CHAPTER 06

Matrix Targets

tile, matrix-vector scores, argmax and onehot

ORIGINAL SOURCE

05-matrix-targets.srp

bind scores = matvec(tile([1.0, 0.0, 0.0, 2.0, -1.0, 1.0], 3, 2), [2.0, 1.0]);
print(onehot(len(scores), argmax(scores)));
EXPECTED OUTPUT

stdout

Verified
[1.0, 0.0, 0.0]

UNDERSTAND THE CODE

Explanation & practice

What this example teaches

tile, matrix-vector scores, argmax and onehot

Expected behavior

[1.0, 0.0, 0.0]

Practice: Read the source before looking at the output. Predict the values and their order, then use the pinned compiler to execute this lesson and compare the exact fixture. Identify which operation produces the result.

मैट्रिक्स स्कोर से वन-हॉट लक्ष्य

tile से 3×2 का मैट्रिक्स और matvec से तीन स्कोर निकाले जाते हैं। argmax अधिकतम स्कोर का इंडेक्स चुनता है और onehot उसी इंडेक्स पर 1 रखता है। यह केवल अंकगणितीय उदाहरण है।

आउटपुट: [1.0, 0.0, 0.0]।

अभ्यास: 2.0 और 1.0 फीचर को मैट्रिक्स की तीन पंक्तियों से गुणा करके स्कोर निकालें।

Explanations are sourced from the project's English chapter guide and हिन्दी अध्याय. The Scarp program and output are unchanged.

TRY IT LOCALLY

Verify, then execute

Use the pinned compiler from the course root. Keep any imported _support files next to the source.

scarp verify examples/06-ai-foundations/05-matrix-targets.srp scarp exec examples/06-ai-foundations/05-matrix-targets.srp

The website does not run code. Read the CLI guide ↗

Pinned compiler: Scarp v0.0.6-alpha.3 · ceff07d9014f. No simulated output.