Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/state_space.py IndexError #510

Open
davek44 opened this issue Jun 5, 2017 · 0 comments
Open

examples/state_space.py IndexError #510

davek44 opened this issue Jun 5, 2017 · 0 comments

Comments

@davek44
Copy link

davek44 commented Jun 5, 2017

Hi, I'm attempting to learn how to use the StateSpace models in GPy. I found an example script examples/state_space.py, but it crashes for me on the StateSpace model.

That is, the line
m2 = GPy.models.StateSpace(X, Y, kernel2)

Produces the following error


IndexError Traceback (most recent call last)
in ()
1 kernel2 = GPy.kern.sde_Matern32(X.shape[1])
----> 2 m2 = GPy.models.StateSpace(X, Y, kernel2)
3 # print(m2)

/Users/davidkelley/anaconda3/lib/python3.5/site-packages/paramz-0.7.3-py3.5.egg/paramz/parameterized.py in call(self, *args, **kw)
52 self.model_initialized = False
53 if initialize:
---> 54 self.initialize_parameter()
55 else:
56 import warnings

/Users/davidkelley/anaconda3/lib/python3.5/site-packages/paramz-0.7.3-py3.5.egg/paramz/core/parameter_core.py in initialize_parameter(self)
329 self.highest_parent._connect_parameters() #logger.debug("calling parameters changed")
330 self.highest_parent._connect_fixes()
--> 331 self.trigger_update()
332
333 @Property

/Users/davidkelley/anaconda3/lib/python3.5/site-packages/paramz-0.7.3-py3.5.egg/paramz/core/updateable.py in trigger_update(self, trigger_parent)
77 #print "Warning: updates are off, updating the model will do nothing"
78 return
---> 79 self._trigger_params_changed(trigger_parent)

/Users/davidkelley/anaconda3/lib/python3.5/site-packages/paramz-0.7.3-py3.5.egg/paramz/core/parameter_core.py in _trigger_params_changed(self, trigger_parent)
126 """
127 [p._trigger_params_changed(trigger_parent=False) for p in self.parameters if not p.is_fixed]
--> 128 self.notify_observers(None, None if trigger_parent else -np.inf)
129
130 def _size_transformed(self):

/Users/davidkelley/anaconda3/lib/python3.5/site-packages/paramz-0.7.3-py3.5.egg/paramz/core/observable.py in notify_observers(self, which, min_priority)
89 which = self
90 if min_priority is None:
---> 91 [callble(self, which=which) for _, _, callble in self.observers]
92 else:
93 for p, _, callble in self.observers:

/Users/davidkelley/anaconda3/lib/python3.5/site-packages/paramz-0.7.3-py3.5.egg/paramz/core/observable.py in (.0)
89 which = self
90 if min_priority is None:
---> 91 [callble(self, which=which) for _, _, callble in self.observers]
92 else:
93 for p, _, callble in self.observers:

/Users/davidkelley/anaconda3/lib/python3.5/site-packages/paramz-0.7.3-py3.5.egg/paramz/core/parameter_core.py in _parameters_changed_notification(self, me, which)
496 """
497 self._optimizer_copy_transformed = False # tells the optimizer array to update on next request
--> 498 self.parameters_changed()
499 def _pass_through_notify_observers(self, me, which=None):
500 self.notify_observers(which=which)

/Users/davidkelley/code/GPy/GPy/models/state_space_model.py in parameters_changed(self)
139 calc_grad_log_likelihood=True,
140 grad_params_no=grad_params_no,
--> 141 grad_calc_params=grad_calc_params)
142
143 if np.any( np.isfinite(log_likelihood) == False):

/Users/davidkelley/code/GPy/GPy/models/state_space_main.py in cont_discr_kalman_filter(cls, F, L, Qc, p_H, p_R, P_inf, X, Y, index, m_init, P_init, p_kalman_filter_type, calc_log_likelihood, calc_grad_log_likelihood, grad_params_no, grad_calc_params)
2783 calc_log_likelihood=calc_log_likelihood,
2784 calc_grad_log_likelihood=calc_grad_log_likelihood, grad_params_no=grad_params_no,
-> 2785 dm_init=dm_init, dP_init=dP_init)
2786
2787 if old_index_shape is not None:

/Users/davidkelley/code/GPy/GPy/models/state_space_main.py in _cont_discr_kalman_filter_raw(cls, state_dim, p_dynamic_callables, p_measurement_callables, X, Y, m_init, P_init, p_kalman_filter_type, calc_log_likelihood, calc_grad_log_likelihood, grad_params_no, dm_init, dP_init)
2967 calc_log_likelihood=calc_log_likelihood,
2968 calc_grad_log_likelihood=calc_grad_log_likelihood,
-> 2969 p_dm = dm_pred, p_dP = dP_pred )
2970 else:
2971 if k_measurment.shape != (1,1):

/Users/davidkelley/code/GPy/GPy/models/state_space_main.py in _kalman_update_step(k, p_m, p_P, p_meas_model_callable, measurement, calc_log_likelihood, calc_grad_log_likelihood, p_dm, p_dP)
1507 P_pred = p_P # from prediction step
1508
-> 1509 H = p_meas_model_callable.Hk(k, m_pred, P_pred)
1510 R = p_meas_model_callable.Rk(k)
1511

/Users/davidkelley/code/GPy/GPy/models/state_space_main.py in Hk(self, k, m_pred, P_pred)
306 """
307
--> 308 return self.H[:, :, self.index[self.H_time_var_index, k]]
309
310 def dHk(self, k):

IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant