Skip to content

Instantly share code, notes, and snippets.

View jamesnordlund's full-sized avatar
🏠
Working from home

James Nordlund jamesnordlund

🏠
Working from home
  • Amazon
  • Frisco, TX
View GitHub Profile
@davidbau
davidbau / runningstats.py
Last active April 18, 2024 11:15
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: