LESSON 48 OF 52 · CHAPTER 06
Log Space
logsumexp and logsoftmax without exponential overflow
07-log-space.srp
// Stable score normalization without exponential overflow.
print(logsumexp([0.0]));
print(logsoftmax([0.0, -1000.0]));
stdout
0.0
[0.0, -1000.0]
Write what you expect this program to print. Check prediction for a line-level hint without revealing the answer, or reveal the verified output when ready. This checks displayed text only; it does not run Scarp or save your input.
UNDERSTAND THE CODE
Explanation & practice
What this example teaches
logsumexp and logsoftmax without exponential overflow
Expected behavior
0.0, then [0.0, -1000.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.
लॉग स्पेस में स्थिर गणना
logsumexp और logsoftmax लॉग स्कोर पर काम करते हैं, जिससे सीधे बहुत बड़े/छोटे exponential निकालने की कठिनाई कम होती है। यह गणितीय सुविधा है, सम्पूर्ण AI framework नहीं।
आउटपुट: पहली पंक्ति 0.0, दूसरी [0.0, -1000.0] है।
अभ्यास: सीधे exp(-1000) निकालने के बजाय log-space में काम करने से क्या लाभ हो सकता है?
Explanations are sourced from the project's English chapter guide and हिन्दी अध्याय. The Scarp program and output are unchanged.
LEARNING PROGRESS
Keep your place
Mark this lesson complete when you are ready.
Only saved in this browser. No account or tracking.
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/07-log-space.srp
scarp exec examples/06-ai-foundations/07-log-space.srpThe website does not run code. Read the CLI guide ↗
Pinned compiler: Scarp v0.0.6-alpha.3
· ceff07d9014f. No simulated output.