JoeZJH / Labeled-LDA-Python

Implement of L-LDA Model(Labeled Latent Dirichlet Allocation Model) with python
MIT License
121 stars 31 forks source link

Error after some iterations #1

Closed rbaral closed 4 years ago

rbaral commented 4 years ago
after iteration: 51, perplexity: 5931.100267564532
delta beta: 5.883340980101
before updating:  
Labeled-LDA Model:
    K = 61
    M = 60120
    T = 130755
    WN = 4029682
    LN = 60120
    alpha = 0.01
    eta = 0.001
    perplexity = 5931.100267564532

after updating:  
Labeled-LDA Model:
    K = 61
    M = 60121
    T = 130763
    WN = 4029695
    LN = 60123
    alpha = 0.01
    eta = 0.001
    perplexity = 5931.23254749438

iteration 52 sampling...
Traceback (most recent call last):
  File "/Users/rr/opt/anaconda3/lib/python3.7/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/Users/rr/opt/anaconda3/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/Users/rr/labeled_lda/mt_llda.py", line 48, in train_model
    llda_model.training(1)
  File "/Users/rr/labeled_lda/labeled_lda.py", line 440, in training
    self._gibbs_sample_training()
  File "/Users/rr/labeled_lda/labeled_lda.py", line 272, in _gibbs_sample_training
    sample_z = LldaModel._multinomial_sample(p_vector)
  File "/Users/rr/labeled_lda/labeled_lda.py", line 218, in _multinomial_sample
    return np.random.multinomial(1, p_vector).argmax()
  File "mtrand.pyx", line 3863, in numpy.random.mtrand.RandomState.multinomial
  File "common.pyx", line 323, in numpy.random.common.check_array_constraint
ValueError: pvals < 0, pvals > 1 or pvals contains NaNs

where the line 47 and line 48

File "/Users/rr/labeled_lda/mt_llda.py", line 48, in train_model
    llda_model.training(1)

creates the object of labeled lda and sends it to training:

llda_model = llda.LldaModel(labeled_documents=labeled_documents, alpha_vector=0.01)
llda_model.training(1)
JoeZJH commented 4 years ago

This project is based on Python2.7, Could you please run the same code with Python2.7, and please tell me if any error occurs. Thank you.