Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |