Dont call parameters_changed ever yourself anymore and parameters are now inplace once in memory

This commit is contained in:
Max Zwiessele 2014-03-04 17:32:46 +00:00
parent 56d749ded8
commit 0df263956f
21 changed files with 601 additions and 284 deletions

View file

@ -19,12 +19,16 @@ class VarDTC(object):
"""
const_jitter = 1e-6
def __init__(self):
def __init__(self, limit=1):
#self._YYTfactor_cache = caching.cache()
from ...util.caching import Cacher
self.get_trYYT = Cacher(self._get_trYYT, 1)
self.get_YYTfactor = Cacher(self._get_YYTfactor, 1)
self.get_trYYT = Cacher(self._get_trYYT, limit)
self.get_YYTfactor = Cacher(self._get_YYTfactor, limit)
def set_limit(self, limit):
self.get_trYYT.limit = limit
self.get_YYTfactor.limit = limit
def _get_trYYT(self, Y):
return param_to_array(np.sum(np.square(Y)))
@ -175,11 +179,14 @@ class VarDTC(object):
return post, log_marginal, grad_dict
class VarDTCMissingData(object):
def __init__(self):
def __init__(self, limit=1):
from ...util.caching import Cacher
self._Y = Cacher(self._subarray_computations, 1)
self._Y = Cacher(self._subarray_computations, limit)
pass
def set_limit(self, limit):
self._Y.limit = limit
def _subarray_computations(self, Y):
inan = np.isnan(Y)
has_none = inan.any()