jaberg/hyperopt — pull request #36 by yamins81 (2011-10-22 22:22:58+00:00)
Title: Feature/multivar gp

First off, I haven't done pep8 stuff b/c the code is going to have to change.

Also: test_4var_unequal is failing in a weird way (full error trace below).

In[3] import hyperopt.tests.test_theano_gp as t

In [4]: se = t.fit_base(t.GPAlgo, t.GaussianBandit4var, 1, 0, 0, 1)
suggest 0 took 0.13 seconds
suggest 1 took 0.01 seconds
suggest 2 took 0.01 seconds
suggest 3 took 0.01 seconds
suggest 4 took 0.01 seconds
suggest 5 took 0.01 seconds
suggest 6 took 0.01 seconds
adding hint Elemwise{add,no_inplace}.0 symmetric True
adding hint Elemwise{add,no_inplace}.0 psd True
AAA Elemwise{pow,no_inplace}.0
is_positive Elemwise{pow,no_inplace}.0
try for pow Elemwise{pow,no_inplace}.0 [ExtractDiag{view=False}.0, InplaceDimShuffle{x}.0]
adding hint Elemwise{add,no_inplace}.0 symmetric True
adding hint Elemwise{add,no_inplace}.0 psd True
ERROR (theano.gof.opt): Optimization failure due to: InplaceDimShuffle{1,0}(dot(x, y)) -> dot(DimShuffle{1,0}(y), DimShuffle{1,0}(x))
ERROR (theano.gof.opt): TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/gof/opt.py", line 893, in process_node
replacements = lopt.transform(node)
File "/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/gof/opt.py", line 741, in transform
new = build(p, u)
File "/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/gof/opt.py", line 730, in build
args = [build(p, u) for p in pattern[1:]]
File "/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/gof/opt.py", line 731, in build
return pattern[0](*args)
File "/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/gof/op.py", line 369, in __call__
node = self.make_node(*inputs, **kwargs)
File "/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/tensor/elemwise.py", line 148, in make_node
raise TypeError("The number of dimensions and/or broadcastable pattern of the input is incorrect for this op. Expected %s, got %s." % (self.input_broadcastable, ib))
TypeError: The number of dimensions and/or broadcastable pattern of the input is incorrect for this op. Expected (False, False), got (True, False).

ERROR (theano.gof.opt): Optimization failure due to: DimShuffle{1,0}(dot(x, y)) -> dot(DimShuffle{1,0}(y), DimShuffle{1,0}(x))
ERROR (theano.gof.opt): TRACEBACK:
ERROR (theano.gof.opt): Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/gof/opt.py", line 893, in process_node
replacements = lopt.transform(node)
File "/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/gof/opt.py", line 741, in transform
new = build(p, u)
File "/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/gof/opt.py", line 730, in build
args = [build(p, u) for p in pattern[1:]]
File "/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/gof/opt.py", line 731, in build
return pattern[0](*args)
File "/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/gof/op.py", line 369, in __call__
node = self.make_node(*inputs, **kwargs)
File "/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/tensor/elemwise.py", line 148, in make_node
raise TypeError("The number of dimensions and/or broadcastable pattern of the input is incorrect for this op. Expected %s, got %s." % (self.input_broadcastable, ib))
TypeError: The number of dimensions and/or broadcastable pattern of the input is incorrect for this op. Expected (False, False), got (True, False).

suggest 7 took 3.29 seconds
---------------------------------------------------------------------------
LinAlgError Traceback (most recent call last)

/Users/dyamins/ in ()

/Users/dyamins/hyperopt/hyperopt/tests/test_theano_gp.pyc in fit_base(A, B, *args, **kwargs)
404 return se
405
--> 406 return run_then_show(50)
407
408

/Users/dyamins/hyperopt/hyperopt/tests/test_theano_gp.pyc in run_then_show(N)
398 A.show = False
399 A.use_base_suggest = True
--> 400 se.run(N - 1)
401 A.show = True
402 A.use_base_suggest = False

/Users/dyamins/hyperopt/hyperopt/experiments.pyc in run(self, N)
27
28 for n in xrange(N):
---> 29 trial = algo.suggest(self.trials, self.results, 1)[0]
30 result = bandit.evaluate(trial, base.Ctrl())
31 if not isinstance(result, (dict, base.SON)):

/Users/dyamins/hyperopt/hyperopt/theano_gp.py in suggest(self, trials, results, N)
893 return self.suggest_ivl(
894 self.suggest_from_model(trials, results, N))
--> 895
896 finally:
897 print 'suggest %i took %.2f seconds' % (

/Users/dyamins/hyperopt/hyperopt/tests/test_theano_gp.pyc in suggest_from_model(self, trials, results, N)
259 if self.use_base_suggest:
260 return GP_BanditAlgo.suggest_from_model(self,
--> 261 trials, results, N)
262
263 ivls = self.idxs_vals_by_status(trials, results)

/Users/dyamins/hyperopt/hyperopt/theano_gp.py in suggest_from_model(self, trials, results, N)
860 prepared_data = self.prepare_GP_training_data(ivls)
861 self.fit_GP(*prepared_data)
--> 862
863 candidates = self.draw_candidates()
864 candidates_opt = self.GP_EI_optimize(candidates)

/Users/dyamins/hyperopt/hyperopt/theano_gp.py in fit_GP(self, x_all, y_all, y_mean, y_var, y_std, maxiter)
729 maxfun=maxiter,
730 bounds=bounds,
--> 731 iprint=-1)
732 logger.info('fit_GP best value: %f' % best_value)
733 set_pt(best_pt)

/Users/dyamins/hyperopt/hyperopt/lbfgsb.pyc in fmin_l_bfgs_b(func, x0, fprime, args, approx_grad, bounds, m, factr, pgtol, epsilon, iprint, maxfun, func_and_grad)
186 n_function_evals += 1
187 # Overwrite f and g:

--> 188 f, g = func_and_grad(x)
189 elif task_str.startswith('NEW_X'):
190 # new iteration

/Users/dyamins/hyperopt/hyperopt/lbfgsb.pyc in func_and_grad(x)
141 else:
142 def func_and_grad(x):
--> 143 f = func(x, *args)
144 g = fprime(x, *args)
145 return f, g

/Users/dyamins/hyperopt/hyperopt/theano_gp.py in f(pt)
696 self._GP_y_all,
697 self._GP_y_var,
--> 698 *self._GP_x_all.flatten())
699 def df(pt):
700 #print 'df', pt

/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/compile/function_module.pyc in __call__(self, *args, **kwargs)
608 t0_fn = time.time()
609 try:
--> 610 self.fn()
611 except Exception:
612 if hasattr(self.fn, 'position_of_error'):

/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/gof/link.pyc in streamline_default_f()
342 old_s[0] = None
343 except Exception:
--> 344 raise_with_op(node)
345 f = streamline_default_f
346 elif nice_errors:

/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/gof/link.pyc in streamline_default_f()
338 try:
339 for thunk, node, old_storage in zip(thunks, order, post_thunk_old_storage):
--> 340 thunk()
341 for old_s in old_storage:
342 old_s[0] = None

/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/gof/op.pyc in rval(p, i, o, n)
544
545 def rval(p=p, i=node_input_storage, o=node_output_storage, n=node):
--> 546 r = p(n, [x[0] for x in i], o)
547 for o in node.outputs:
548 compute_map[o][0] = True

/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/Theano-0.4.1-py2.7.egg/theano/sandbox/linalg/ops.pyc in perform(self, node, (x,), (z,))
322 return Apply(self, [x], [x.type()])
323 def perform(self, node, (x,), (z,)):
--> 324 z[0] = scipy.linalg.cholesky(x, lower=self.lower).astype(x.dtype)
325 #def grad(self, (x, y), (gz,)):

326 #return dot(gz, y), dot(x, gz) #no transposing necessary

/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/scipy/linalg/decomp_cholesky.pyc in cholesky(a, lower, overwrite_a)
64
65 """
---> 66 c, lower = _cholesky(a, lower=lower, overwrite_a=overwrite_a, clean=True)
67 return c
68

/usr/local/Cellar/python/2.7/lib/python2.7/site-packages/scipy/linalg/decomp_cholesky.pyc in _cholesky(a, lower, overwrite_a, clean)
22 c, info = potrf(a1, lower=lower, overwrite_a=overwrite_a, clean=clean)
23 if info > 0:
---> 24 raise LinAlgError("%d-th leading minor not positive definite" % info)
25 if info < 0:
26 raise ValueError('illegal value in %d-th argument of internal potrf'

LinAlgError: 6-th leading minor not positive definite