Skip to content
Snippets Groups Projects

add 'save' and 'load' to the learners and periodic saving to the Runner

Merged Bas Nijholt requested to merge saving into master
All threads resolved!
Compare and Show latest version
68 files
+ 2931
436
Compare changes
  • Side-by-side
  • Inline
Files
68
# -*- coding: utf-8 -*-
import itertools
from math import sqrt
import numpy as np
from ..notebook_integration import ensure_holoviews
from .base_learner import BaseLearner
from ..notebook_integration import ensure_holoviews
from ..utils import cache_latest
class AverageLearner(BaseLearner):
@@ -17,9 +17,9 @@ class AverageLearner(BaseLearner):
Parameters
----------
atol : float
Desired absolute tolerance
Desired absolute tolerance.
rtol : float
Desired relative tolerance
Desired relative tolerance.
Attributes
----------
@@ -88,8 +88,13 @@ class AverageLearner(BaseLearner):
n = self.npoints
if n < 2:
return np.inf
return sqrt((self.sum_f_sq - n * self.mean**2) / (n - 1))
numerator = self.sum_f_sq - n * self.mean**2
if numerator < 0:
# in this case the numerator ~ -1e-15
return 0
return sqrt(numerator / (n - 1))
@cache_latest
def loss(self, real=True, *, n=None):
if n is None:
n = self.npoints if real else self.n_requested
Loading