We can't find the internet
Attempting to reconnect
Something went wrong!
Attempting to reconnect
← Activations step 8 of 9
Easy
Primitives
Implement Softmax
Implement the softmax function from scratch.
The softmax function converts a vector of real numbers into a probability distribution:
$$\text{softmax}(x_i) = \frac{e^{x_i}}{\sum_{j} e^{x_j}}$$
Input: A 1D tensor x of shape (n,)
Output: A 1D tensor of the same shape where all values sum to 1.0
Note: For numerical stability, subtract the max value before exponentiating: $\text{softmax}(x_i) = \frac{e^{x_i - \max(x)}}{\sum_{j} e^{x_j - \max(x)}}$
Loading visualization…
Nothing accepted yet. When a submission passes, the code that passed shows up
here, one entry per mode.
Stuck?
PyTorch reference solution
Sign in to attempt this problem and reveal the reference solution.