コード例 #1
0
ファイル: Rosenbrock.py プロジェクト: TerryLew/BinLOTlib
 def __init__(self, value=None):
     if value is None:
         value = numpy.array([0.0, 0.0])
     VectorHypothesis.__init__(self,
                               value=value,
                               n=2,
                               proposal=numpy.eye(2) * 0.1)
コード例 #2
0
ファイル: GrammarHypothesis.py プロジェクト: pratiksha/LOTlib
 def __init__(
     self,
     grammar,
     hypotheses,
     rules=None,
     load=None,
     value=None,
     proposal=None,
     prior_shape=2.0,
     prior_scale=1.0,
     propose_n=1,
     propose_step=0.1,
     **kwargs
 ):
     self.grammar = grammar
     if load:
         self.hypotheses = self.load_hypotheses(load)
     else:
         self.hypotheses = hypotheses
     self.rules = [r for sublist in grammar.rules.values() for r in sublist]
     if value is None:
         value = [rule.p for rule in self.rules]
     self.n = len(value)
     self.propose_idxs = self.get_propose_idxs()
     if proposal is None:
         proposal = np.eye(len(self.propose_idxs))
     VectorHypothesis.__init__(self, value=value, n=self.n, proposal=proposal)
     self.prior_shape = prior_shape
     self.prior_scale = prior_scale
     self.propose_n = propose_n
     self.propose_step = propose_step
     # self.compute_prior()
     self.update()
コード例 #3
0
ファイル: GrammarHypothesis.py プロジェクト: moverlan/LOTlib
 def __init__(self, grammar, hypotheses, rules=None, load=None, value=None,
              prior_shape=2., prior_scale=1., propose_n=1, propose_step=.1,
              **kwargs):
     self.grammar = grammar
     self.hypotheses = self.load_hypotheses(load) if load else hypotheses
     self.rules = [r for sublist in grammar.rules.values() for r in sublist]
     if value is None:
         value = [rule.p for rule in self.rules]
     self.n = len(value)
     VectorHypothesis.__init__(self, value=value, n=self.n, **kwargs)
     self.prior_shape = prior_shape
     self.prior_scale = prior_scale
     if int(self.n / 50) > propose_n:
         propose_n = int(self.n / 50)
     self.propose_n = propose_n
     self.propose_step = propose_step
     self.propose_idxs = self.get_propose_idxs()
     self.compute_prior()
     self.update()
コード例 #4
0
ファイル: Rosenbrock.py プロジェクト: jthurst3/LOTlib
 def __init__(self, value=None):
     if value is None: value = numpy.array([0.0, 0.0])
     VectorHypothesis.__init__(self, value=value, N=2, proposal=numpy.eye(2)*0.1)