Choose a language and read the cells in order. These are small teaching examples; the visual lesson runs separately.
Follow the calculation
Same inputs · Same operation · Same result
3 teaching cells · Python standard library · Read-only
1. Prepare the inputs
The three block sums from the lesson's flattened list (each class adds up its own block of pooled values), the shared block weight 0.2 and the three hand-picked biases: watermelon, fried egg, mug.
import json import math block_sums = [6.8546, 1.0200, 3.9593] weight = 0.2 biases = [-0.1, 0.2, 0.1]2. Score, then share
Each class score is its weighted sum plus its bias. Stable softmax subtracts the largest score, takes powers of e and divides by their total.
scores = [weight * s + b for s, b in zip(block_sums, biases)] biggest = max(scores) powers = [math.exp(z - biggest) for z in scores] result = [round(p / sum(powers), 3) for p in powers]3. Inspect the result
Print the shares as JSON so both languages use the same output format. The largest share follows the hand-picked weights, not any learning.
print(json.dumps(result))
Expected result
Running the three cells in order produces this result in either language.
[
0.475,
0.2,
0.325
]