Fitz-like-coding / CWTM

2 stars 0 forks source link

IndexError raised after the training finished. #1

Closed AEGISEDGE closed 1 month ago

AEGISEDGE commented 2 months ago

Thank u for sharing ur code. When I tried to run run_reproduce.py, it raised an IndexError after model traning:

Traceback (most recent call last):
  File "/home/devuser/cwtm/run_reproduce.py", line 128, in <module>
    main(parser.parse_args())
  File "/home/devuser/cwtm/run_reproduce.py", line 102, in main
    topics = model.get_topics(top_k=10)
  File "/home/devuser/cwtm/model.py", line 407, in get_topics
    topics[i] = [w for w in vobs[topic2word[i].argsort()[::-1]]][:top_k]
IndexError: index 0 is out of bounds for axis 0 with size 0

It seems that the self.word2topic is empty after the training. I wonder how can I fix this. Thank u!

Fitz-like-coding commented 2 months ago

Hi @AEGISEDGE, thanks for pointing out the issue. I have fixed the issue now. What to do is to call extracting_topics function before the get_topics function.

AEGISEDGE commented 2 months ago

I tried ur solution, but in line 92:

model.extracting_topics(texts, min_df=3, max_df=0.95, remove_top=10, stopwords=stopwords)

text variable is not defined. I look through the context but fail to find its definition.

Fitz-like-coding commented 2 months ago

fixed now