Closed gxhrid closed 9 years ago
Linear algebra errors are probably data-dependent. Would it be possible to send me a script and a data file that reproduce this error so I can check it out?
Generally speaking, increasing the strength of the prior can make things better conditioned by boosting the diagonals of these matrices. What are your prior hyperparameters?
I have sent the corespond materials to reproduce this issue in E-maiil.
Thank you for your remiding of chaging the prior hyperparameters. I will try this.
In light of your reminding, I have chaged the prior hyperparameters from
obs_hypparams = dict(mu_0=np.zeros(2),sigma_0=np.eye(2),kappa_0=0.2,nu_0=5)
to using the mean and std of data to init the hyperparams as following,
temp = np.vstack(data)
mu_0 = np.mean(temp, 0)
sigma_0 = np.eye(2) * np.std(temp, 0) ** 2
del temp
obs_hypparams = dict(mu_0=mu_0, sigma_0=sigma_0, kappa_0=0.2,nu_0=5)
It is run well now. Previously, I think the prior is only play a role of regularization, which does not matters especially for the big data scenario.
the entire script :
num_states = 20
data = []
data.append(np.array([[ 46.09624038, -60.75663923]] ))
data.append(np.array([[ 45.67615317, -62.71079608],
[ 46.42577037, -62.59713028],
[ 46.23305503, -62.61693047]]))
data.append(np.array([[ 47.39252692, -61.78993208]] ))
data.append(np.array([[ 45.94008088, -66.61341137],
[ 46.81245472, -71.2273164 ]]))
data.append(np.array([[ 45.44950604, -73.74036312]] ))
temp = np.vstack(data)
mu_0 = np.mean(temp, 0)
sigma_0 = np.eye(2) * np.std(temp, 0) ** 2
del temp
obs_hypparams = dict(mu_0=mu_0, sigma_0=sigma_0, kappa_0=0.2,nu_0=5)
hmm = models.HMM(
obs_distns=[distributions.Gaussian(**obs_hypparams) for i in range(num_states)],
alpha=10.,init_state_concentration=1.)
vlb = []
for i in range(10):
vlb.append(hmm.meanfield_batch_cdstep(data, num_procs = 0))
I feed many seqences data to pyhsmm. and want to use the meanfield inference method of HMM model.
But there always occures the "Matrix is not positive definite" exception, and the stack information is attached. My data are a little bit big and the programe is paralleled. So, it is very hard for me to treat this in a short time.
is there anything wrong in my raw data not to meet the model's data specification? or is this a inherenet error of this model? maybe I should change other random seed?
Traceback: