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
      91 of 102

      A small change to a big matrix

      Fine-tuning a model changed one of its big matrices of weights. Storing the whole change costs as much as the matrix itself, but this change is special: every row is the same pattern, scaled by some amount. Write compress(change): return two short lists, [column, row], that rebuild it: change[i][j] = column[i] * row[j] for every i and j.

      Fine-tuning changed a grid of weights, and storing the change costs as much as the grid. But look at the rows: every one is the same pattern times some amount. Store an amount per row and the pattern, and a million numbers become two thousand.

      The change fine-tuning made to a matrix of weights.the change · 3 × 3 = 9 numbers123= 1 × [1, 2, 3]246= 2 × [1, 2, 3]−1−2−3= −1 × [1, 2, 3]store insteada column of 3 amountsand one row of 36 numbers, not 9for 1000 × 1000:2000, not 1000000compress(change) → [column, row] with change[i][j] = column[i] × row[j]?
      Your functioncompress(change)
      changea list of rows, every row the same pattern times some amounte.g. [[2, −4, 6, 1, −2], [1, −2, 3, 0.5, −1], […
      returns[column, row] with change[i][j] == column[i] * row[j]
      solution.pyLoading Python
      Sign in for an AI hint
      ← Find your twinA reward now or later →