LESSON 31 OF 52 · CHAPTER 04

Numerical Kernels

variance, stddev, relu, sigmoid and tanh on numeric data

ORIGINAL SOURCE

07-numerical-kernels.srp

bind samples = ints_to_vector(ints_range(-2, 5, 1));
print(variance(samples), stddev([3.0, 3.0]));
print(relu(samples));
print(sigmoid([-1000.0, 0.0, 1000.0]));
print(tanh([-1000.0, 0.0, 1000.0]));
EXPECTED OUTPUT

stdout

Verified
2.0 0.0
[0.0, 0.0, 0.0, 1.0, 2.0]
[0.0, 0.5, 1.0]
[-1.0, 0.0, 1.0]

UNDERSTAND THE CODE

Explanation & practice

What this example teaches

variance, stddev, relu, sigmoid and tanh on numeric data

Expected behavior

2.0 0.0 and three vectors

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.

संख्यात्मक फ़ंक्शन

variance संख्याओं का फैलाव और stddev मानक विचलन देता है। relu ऋणात्मक मानों को शून्य करता है; sigmoid और tanh संख्याओं को सीमित दायरों में बदलते हैं। यह फ़ंक्शन-स्तरीय गणना है, प्रशिक्षित न्यूरल नेटवर्क नहीं।

आउटपुट: पहले 2.0 0.0 और फिर तीन परिणाम वेक्टर: [0.0, 0.0, 0.0, 1.0, 2.0], [0.0, 0.5, 1.0], और [-1.0, 0.0, 1.0]।

अभ्यास: relu में -2.0 और -1.0 के लिए 0.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/04-collections/07-numerical-kernels.srp scarp exec examples/04-collections/07-numerical-kernels.srp

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

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