Spooky Sale: 10% off Premium yearly · $118.80 for the first year · until Nov 6Get it

Deep-ML
Learn
Problems1,200+ hands-on ML problemsLearning PathA guided route through the fundamentalsLabsInteractive labs on real techniquesProjectsBuild a GPT, an RL agent, CUDA kernelsCollectionsCurated problem sets and videosMathPen-and-paper math for MLIntuitionInvent the idea behind the formula yourselfPlaylistsYour own problem lists, shareableStudy AssistantAn AI teacher that knows your progress
Interview Prep
Compete
ContestsFresh problem sets, ranked liveLeaderboardWhere you stand, globallyBuddiesSolve with a friend: streaks, a weekly board, chat
Discuss
Deep-Path
Premium
      Intuition
      74 of 88

      Softmax on the go

      Softmax (“Scores into chances”) divides each exp(score) by the total of them all. Scores now arrive one at a time and can’t be kept, so keep a small state instead: [biggest, total], the biggest score so far and total = Σ exp(score − biggest) over the scores so far, measured from that biggest one so nothing overflows. Before the first score the state is None. Write update(state, score): the new state after one more score arrives.

      scores, arriving one at a time
      1st2nd3rd
      2−14
      the state after each
      biggesttotal
      1st21
      2nd21.05
      3rd41.142
      solution.pyLoading Python
      ← Distance, not placeThe greedy trap →