learning.moments

Contents

learning.moments#

bartorch.learning.moments()#

Mean and variance of a randomized reconstruction, voxel by voxel.

reconstruct is called samples times without gradient, and each result is folded into running moments (Welford’s update), so memory holds the mean, the sum of squares and one result whatever samples is. The spread measures whatever randomness the reconstruction draws: the patch grid of a Patchwise network with shift=True, dropout left active in a network, or the acquired samples a reconstruction from a split() of them keeps. Each is a distinct and partial measure of the error, and none is a posterior; calibrate() relates the spread to the error actually made on references.

Parameters:
  • reconstruct (callable) – Called with no argument; returns the reconstructed image, complex or real, the same shape every time.

  • samples (int, default=8) – Number of reconstructions.

Returns:

mean, variance – On the device and with the shape of a reconstruction; the variance is real, E|x - mean|^2 with the unbiased samples - 1 divisor.

Return type:

torch.Tensor