DataLane

Python problem track

Tensors & ranking

Softmax, log-softmax, cosine, top-k, KL, Huber — the DS/MLE follow-up after the metric pad.

8 problems · ~102 min total · Data Scientist · ML Engineer · MLOps Engineer · AI Engineer

Track progress 0/8

0% complete

Start with problem 1
  1. Step 1 · ~12 min · OpenAI, Google

    Softmax

    Implement softmax(x): exp(x - max(x)) / sum(exp(x - max(x))). Return a list of floats rounded to 4 decimals.

    PythonNumPyPyTorch
    hardProNot started
  2. Step 2 · ~12 min · OpenAI, Anthropic

    Log-softmax

    Return log(softmax(x)) with the max-subtraction trick, as a list of floats rounded to 4 decimals.

    PythonNumPyPyTorch
    hardProNot started
  3. Step 3 · ~12 min · OpenAI, Google

    Cosine similarity

    Return cosine similarity of equal-length vectors a and b, rounded to 4 decimals. Assume they are non-zero.

    PythonNumPyPyTorch
    hardProNot started
  4. Step 4 · ~12 min · Google, NVIDIA

    Top-k indices

    Return the indices of the k largest values in x, largest first. Ties keep the earlier index.

    PythonNumPyPyTorch
    hardProNot started
  5. Step 5 · ~14 min · DeepMind, Two Sigma

    KL divergence

    Kullback–Leibler divergence KL(p || q) in nats: sum p_i log(p_i / q_i). Skip zeros in p. Assume q_i > 0 wherever p_i > 0. Round to 4 decimals.

    PythonNumPyPyTorch
    hardProNot started
  6. Step 6 · ~14 min · NVIDIA, Jane Street

    Huber loss

    Mean Huber loss of labels y and predictions yhat with delta = 1. For each residual r = yhat - y: 0.5 r^2 if |r| <= 1, else |r| - 0.5. Round to 4 decimals.

    PythonNumPyPyTorch
    hardProNot started
  7. Step 7 · ~12 min · DeepMind, Google

    Shannon entropy

    Shannon entropy of a discrete distribution p (nats, natural log): -sum p_i log(p_i). Skip zeros. Round to 4 decimals.

    PythonNumPyPyTorch
    hardProNot started
  8. Step 8 · ~14 min · Two Sigma, Citadel

    Pearson correlation

    Return the Pearson correlation of equal-length vectors a and b, rounded to 4 decimals. Assume they are not constant.

    PythonNumPyPyTorch
    hardProNot started

Other tracks

↑↓ navigate openesc close