Skip to content

Instantly share code, notes, and snippets.

View jamesnordlund's full-sized avatar

James Nordlund jamesnordlund

  • Amazon
  • Redmond, WA
  • 01:46 (UTC -07:00)
View GitHub Profile
@davidbau
davidbau / runningstats.py
Last active June 10, 2024 21:43
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: