Skip to content

Instantly share code, notes, and snippets.

View jamesnordlund's full-sized avatar

James Nordlund jamesnordlund

  • Amazon
  • Redmond, WA
  • 01:58 (UTC -08:00)
View GitHub Profile
@davidbau
davidbau / runningstats.py
Last active September 11, 2025 18:33
Running stats objects for pytorch: mean, variance, covariance, second-moment, quantiles, topk, and combinations.
'''
To use a runningstats object,
1. Create the the desired stat object, e.g., `m = Mean()`
2. Feed it batches via the add method, e.g., `m.add(batch)`
3. Repeat step 2 any number of times.
4. Read out the statistic of interest, e.g., `m.mean()`
Built-in runningstats objects include: