Lab 00 - Warmup¶
Goal: refresh basic Python operations used in later labs.
Info: Basic operations and softmax
These cells demonstrate foundation for probability calculations. Softmax converts raw model scores (logits) into normalized probabilities.
In [1]:
Copied!
tickets = [12, 24, 8, 17, 31]
print("Ticket lengths:", tickets)
print("Count:", len(tickets))
print("Average length:", sum(tickets) / len(tickets))
tickets = [12, 24, 8, 17, 31]
print("Ticket lengths:", tickets)
print("Count:", len(tickets))
print("Average length:", sum(tickets) / len(tickets))
Ticket lengths: [12, 24, 8, 17, 31] Count: 5 Average length: 18.4
In [2]:
Copied!
scores = [1.2, 0.7, -0.3]
shift = max(scores)
exp_shifted = [2.718281828 ** (s - shift) for s in scores]
probs = [v / sum(exp_shifted) for v in exp_shifted]
print("Softmax-like probabilities:", [round(p, 4) for p in probs])
print("Sum:", round(sum(probs), 6))
scores = [1.2, 0.7, -0.3]
shift = max(scores)
exp_shifted = [2.718281828 ** (s - shift) for s in scores]
probs = [v / sum(exp_shifted) for v in exp_shifted]
print("Softmax-like probabilities:", [round(p, 4) for p in probs])
print("Sum:", round(sum(probs), 6))
Softmax-like probabilities: [0.5465, 0.3315, 0.122] Sum: 1.0