Skip to content

Instantly share code, notes, and snippets.

@calebrob6
calebrob6 / running_stats_in_torch.py
Last active July 7, 2024 08:48
A class for computing online mean and variance of multi-dimensional arrays in PyTorch (i.e. for computing per-channel stats over large image datasets).
import torch
class RunningStatsButFast(torch.nn.Module):
def __init__(self, shape, dims):
"""Initializes the RunningStatsButFast method.
A PyTorch module that can be put on the GPU and calculate the multidimensional
mean and variance of inputs online in a numerically stable way. This is useful
for calculating the channel-wise mean and variance of a big dataset because you
don't have to load the entire dataset into memory.
@wiseodd
wiseodd / llla_img2img.ipynb
Created November 23, 2022 13:38
Last-Layer Laplace for Image2Image Problems
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.