Dear Gordon, thank you for taking this. I appreciate your help. This is my code:
class EpochLogger(CoherenceMetric):
def __init__(self):
self.epoch = 0
def on_epoch_begin(self, model):
print("Epoch #{} start".format(self.epoch))
def on_epoch_end(self, model):
print("Epoch #{} end".format(self.epoch))
self.epoch += 1
id2word = dictionary
corpus = bow_corpus
epoch_logger = EpochLogger()
lda_model = gensim.models.ldamodel.LdaModel(corpus=corpus,
id2word=id2word,
num_topics=10, #
Anzahl der topics
random_state=100,
# random state zum reproduzieren der Ergebnisse
chunksize=1000, #
Anzahl Dokumente, die auf ein Mal in den Arbeitsspeicher geladen
werden
update_every=1, #
Anzahl von chunks, die auf ein Mal bearbeitet werden.
eval_every=10, #
Schätzung der log-perplexity (Maß für Modellgüte)
passes=10, #
Anzahl wie häufig der Alg. durch den gesamten Datensatz geht
alpha='symmetric',
# prior für die Dokumenten-Topic Verteilung
eta ='symmetric',
# prior für die Topic-Wort Verteilung
iterations=100, #
Anzahl der Iterationen
per_word_topics=True, # Wenn auf True gesetzt berechnet das
Modell auch eine Liste mit wahrscheinlichsten Topics für jedes
Wort
callbacks=[epoch_logger])
And this is the full traceback:
--------------------------------------------------------------------------- AttributeError Traceback (most recent call last) Cell In[16], line 6 3 corpus = bow_corpus 4 epoch_logger = EpochLogger() ----> 6 lda_model = gensim.models.ldamodel.LdaModel(corpus=corpus, 7 id2word=id2word, 8 num_topics=10, # Anzahl der topics 9 random_state=100, # random state zum reproduzieren der Ergebnisse 10 chunksize=1000, # Anzahl Dokumente, die auf ein Mal in den Arbeitsspeicher geladen werden 11 update_every=1, # Anzahl von chunks, die auf ein Mal bearbeitet werden. 12 eval_every=10, # Schätzung der log-perplexity (Maß für Modellgüte) 13 passes=10, # Anzahl wie häufig der Alg. durch den gesamten Datensatz geht 14 alpha='symmetric', # prior für die Dokumenten-Topic Verteilung 15 eta ='symmetric', # prior für die Topic-Wort Verteilung 16 iterations=100, # Anzahl der Iterationen 17 per_word_topics=True, # Wenn auf True gesetzt berechnet das Modell auch eine Liste mit wahrscheinlichsten Topics für jedes Wort 18 callbacks=[epoch_logger]) 21 # Um zu sehen, was gensim tut müssen wir in den log file schauen! File /opt/conda/lib/python3.11/site-packages/gensim/models/ldamodel.py:521, in LdaModel.__init__(self, corpus, num_topics, id2word, distributed, chunksize, passes, update_every, alpha, eta, decay, offset, eval_every, iterations, gamma_threshold, minimum_probability, random_state, ns_conf, minimum_phi_value, per_word_topics, callbacks, dtype) 519 use_numpy = self.dispatcher is not None 520 start = time.time() --> 521 self.update(corpus, chunks_as_numpy=use_numpy) 522 self.add_lifecycle_event( 523 "created", 524 msg=f"trained {self} in {time.time() - start:.2f}s", 525 ) File /opt/conda/lib/python3.11/site-packages/gensim/models/ldamodel.py:973, in LdaModel.update(self, corpus, chunksize, decay, offset, passes, update_every, eval_every, iterations, gamma_threshold, chunks_as_numpy) 970 if self.callbacks: 971 # pass the list of input callbacks to Callback class 972 callback = Callback(self.callbacks) --> 973 callback.set_model(self) 974 # initialize metrics list to store metric values after every epoch 975 self.metrics = defaultdict(list) File /opt/conda/lib/python3.11/site-packages/gensim/models/callbacks.py:480, in Callback.set_model(self, model) 478 # store diff diagonals of previous epochs 479 self.diff_mat = Queue() --> 480 if any(metric.logger == "visdom" for metric in self.metrics): 481 if not VISDOM_INSTALLED: 482 raise ImportError("Please install Visdom for visualization") File /opt/conda/lib/python3.11/site-packages/gensim/models/callbacks.py:480, in <genexpr>(.0) 478 # store diff diagonals of previous epochs 479 self.diff_mat = Queue() --> 480 if any(metric.logger == "visdom" for metric in self.metrics): 481 if not VISDOM_INSTALLED: 482 raise ImportError("Please install Visdom for visualization") AttributeError: 'EpochLogger' object has no attribute 'logger' I am running the code in a jupyter notebook on the jupyter hub of our university. Many thanks, Felix
--
You received this message because you are subscribed to the Google Groups "Gensim" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gensim+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gensim/d2701d66-db55-48b7-9617-94505b9e5b22n%40googlegroups.com.