Add Jurse3 protocol with cache
This commit is contained in:
parent
2081f87293
commit
4a3e1bf442
@ -10,3 +10,4 @@
|
||||
|
||||
#from .jurse import Jurse
|
||||
from .jurse2 import Jurse2
|
||||
from .jurse3 import Jurse3
|
||||
|
35
minigrida/protocols/jurse3.py
Normal file
35
minigrida/protocols/jurse3.py
Normal file
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env python
|
||||
# file jurse3.py
|
||||
# author Florent Guiotte <florent.guiotte@irisa.fr>
|
||||
# version 0.0
|
||||
# date 17 sept. 2021
|
||||
|
||||
import importlib
|
||||
|
||||
from joblib import Memory
|
||||
from pathlib import Path
|
||||
|
||||
from . import Jurse2
|
||||
|
||||
CACHE = './cache'
|
||||
|
||||
|
||||
class Jurse3(Jurse2):
|
||||
"""Jurse2 protocl with cache
|
||||
|
||||
Same as Jurse2 but enable caching results to speed up
|
||||
hyperparameters tunning.
|
||||
"""
|
||||
def __init__(self, expe):
|
||||
super().__init__(expe)
|
||||
|
||||
self.memory = Memory(CACHE if Path(CACHE).exists else None, verbose=0)
|
||||
|
||||
def _compute_descriptors(self, data):
|
||||
script = self._expe['descriptors_script']
|
||||
|
||||
desc = importlib.import_module(script['name'])
|
||||
run = self.memory.cache(desc.run)
|
||||
att = run(*data, **script['parameters'])
|
||||
|
||||
return att
|
Loading…
Reference in New Issue
Block a user