Premium problem39. Softmax

Medium Locked

Transform the 1-D tensor x into a probability distribution: exponentiate each element, then divide by the sum of all the exponentials, so the outputs are non-negative and sum to 1.

Input

tensor([1., 2., 3.])

Output

tensor([0.0900, 0.2447, 0.6652])

Premium problem

This one's part of Premium. Unlock the full PyTorch track plus every other premium problem on the site.

Implement solve(...)