adaptive icon indicating copy to clipboard operation
adaptive copied to clipboard

LearnerND not loading properly

Open MrCheatak opened this issue 1 year ago • 1 comments

Consider a problem, where one would like to save an intermediate learning result and continue later. i.e. to increase accuracy.

Saving and loading Learner2D works like charm and I can continue where I left off, but loading a LearnerND throws an error: learner.function cannot be pickled.

Here is a reproducible example for a notebook:

from adaptive import LearnerND, Runner, notebook_extension
notebook_extension()

def sphere(xyz):
    x, y, z = xyz
    return x**2 + y**2 + z**2

fname = r'sphere_learned.pkl'
learner = LearnerND(sphere, bounds=[(-3, 3), (-3, 3), (-3, 3)])
runner = Runner(learner, loss_goal=0.01, ntasks=4)
runner.live_info()
runner.start_periodic_saving(save_kwargs=dict(fname=fname), interval=10)
learner = LearnerND(sphere, bounds=[(-3, 3), (-3, 3), (-3, 3)])
learner.load(fname)
runner = Runner(learner, loss_goal=0.001)

MrCheatak avatar Aug 08 '24 10:08 MrCheatak