Open andrewcz opened 6 years ago
I got the same error. Hope someone can help!
I got another problem when running simle_demo.py:
Traceback (most recent call last):
File "/Users/Veronica 1/slds_trial.py", line 94, in
And when I try with an even simpler example myself, like this:
import numpy as np
import numpy.random as npr
from pyslds.models import DefaultSLDS
K = 5
D_obs = 10
D_latent = 2
T = 20
n_sample = 10
data = npr.randn(n_sample*T*D_obs).reshape(n_sample, T, D_obs)
test_model = DefaultSLDS(K, D_obs, D_latent)
for sample in data:
test_model.add_data(sample)
print("Initializing with Gibbs")
N_gibbs_samples = 100
def initialize(model):
model.resample_model()
return model.log_likelihood()
gibbs_lls = [initialize(test_model) for _ in range(N_gibbs_samples)]
print("Fitting with VBEM")
N_vbem_iters = 100
def update(model):
model.VBEM_step()
return model.log_likelihood()
test_model._init_mf_from_gibbs()
vbem_lls = [update(test_model) for _ in range(N_vbem_iters)]
I got another error:
Traceback (most recent call last):
File "/Users/Veronica 1/slds_simple_demo.py", line 32, in
Could you kindly give some help with this? Thanks a lot!
As for the error "FloatingPointError: invalid value encountered in multiply", it is because some log transition is -inf. So you only need to add "log_transmatrix[np.isinf(log_transmatrix)] = -1e+8" and it then works.
hey champion just getting some errors on the simple example
......................... [ 825/1000, 0.04sec avg, ETA 6.19 ] ......................... [ 850/1000, 0.04sec avg, ETA 5.31 ] ......................... [ 875/1000, 0.04sec avg, ETA 4.42 ] ......................... [ 900/1000, 0.04sec avg, ETA 3.54 ] ......................... [ 925/1000, 0.04sec avg, ETA 2.65 ] ......................... [ 950/1000, 0.04sec avg, ETA 1.77 ] ......................... [ 975/1000, 0.04sec avg, ETA 0.88 ] ......................... [ 1000/1000, 0.04sec avg, ETA 0.00 ]
0.04sec avg, 35.35 total
Fitting with VBEM ................/home/andrewcz/anaconda3/lib/python3.6/site-packages/pyhsmm/internals/hmm_states.py:675: RuntimeWarning: divide by zero encountered in log np.log(trans_potential),likelihood_log_potential,alphal,betal, /home/andrewcz/pyslds/pyslds/states.py:594: RuntimeWarning: divide by zero encountered in log params = (np.log(self.trans_matrix), np.log(self.pi_0), aBl, self._normalizer) Traceback (most recent call last): File "simple_demo.py", line 95, in
vbem_lls = [update(testmodel) for in progprint_xrange(N_vbem_iters)]
File "simple_demo.py", line 95, in
vbem_lls = [update(testmodel) for in progprint_xrange(N_vbem_iters)]
File "simple_demo.py", line 91, in update
model.VBEM_step()
File "/home/andrewcz/pyslds/pyslds/models.py", line 217, in VBEM_step
self._vb_E_step()
File "/home/andrewcz/pyslds/pyslds/models.py", line 170, in _vb_E_step
state.vb_E_step()
File "/home/andrewcz/pyslds/pyslds/states.py", line 586, in vb_E_step
H_z = self.vb_E_step_discrete_states()
File "/home/andrewcz/pyslds/pyslds/states.py", line 595, in vb_E_step_discrete_states
return hmm_entropy(params, self.all_expected_stats)
File "/home/andrewcz/pyslds/pyslds/util.py", line 63, in hmm_entropy
neg_entropy += np.sum(sum_E_ztztp1T * log_transmatrix)
FloatingPointError: invalid value encountered in multiply
best andrew