Skip to content

Commit 38c7fc5

Browse files
committed
formatting oRSM.py and RSM.py
1 parent 442cd33 commit 38c7fc5

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

octis/models/RSM.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def build_dtm(self, tokenized_corpus, id2word = None):
195195
"""
196196
converts a tokenized corpus to a DOcument Term Matrix. id2word is a gensim dictionary.
197197
"""
198-
if (id2word == None):
198+
if (id2word is None):
199199
id2word = corpora.Dictionary(tokenized_corpus)
200200
else:
201201
id2word = id2word
@@ -309,7 +309,7 @@ def hidden2visible(self, h):
309309
def topic_words(self, topk, id2word=None):
310310
w_vh, w_v, w_h = self.W
311311
T = self.hidden
312-
if id2word==None:
312+
if id2word is None:
313313
id2word = self.id2word
314314
words = np.array([k for k in id2word.token2id.keys()])
315315

@@ -476,7 +476,6 @@ def gradient_momentum(self, v1, v2, h1, h2):
476476
def gradient_adagrad(self, v1, v2, h1, h2):
477477
w_vh, w_v, w_h = self.W
478478
vel_vh, vel_v, vel_h = self.train_cache
479-
m = self.momentum
480479
lr = self.lr
481480

482481
vel_vh = np.dot(v1.T, h1) - np.dot(v2.T, h2)
@@ -498,7 +497,6 @@ def gradient_adagrad(self, v1, v2, h1, h2):
498497
def gradient_rmsprop(self, v1, v2, h1, h2):
499498
w_vh, w_v, w_h, = self.W
500499
vel_vh, vel_v, vel_h, rms_m2_vh, rms_m2_v, rms_m2_h = self.train_cache
501-
m = self.momentum
502500
rms_decay = self.rms_decay
503501
lr = self.lr
504502

@@ -589,7 +587,6 @@ def mfcd_step(self, v0):
589587
self.gradient_step(v0,v1,h0,h1)
590588

591589
def pcd_step(self, v0, pv0):
592-
D = v0.sum(axis=1)
593590
h0 = self.visible2hidden(v0)
594591
pv1 = self.gibbs_transition(pv0)
595592
ph1 = self.visible2hidden(pv1)

octis/models/oRSM.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ def build_dtm(self, tokenized_corpus, id2word = None):
151151
"""
152152
converts a tokenized corpus to a DOcument Term Matrix. id2word is a gensim dictionary.
153153
"""
154-
if (id2word == None):
154+
if (id2word is None):
155155
id2word = corpora.Dictionary(tokenized_corpus)
156156
else:
157157
id2word = id2word
@@ -388,7 +388,6 @@ def gradient_momentum(self, v1, v2, h11, h12 , h21, h22):
388388
def gradient_adagrad(self, v1, v2, h11, h12 , h21, h22):
389389
w_vh, w_v, w_h = self.W
390390
vel_vh, vel_v, vel_h = self.train_cache
391-
m = self.momentum
392391
lr = self.lr
393392

394393
vel_vh = np.dot((v1 + h21).T, h11) - np.dot((v2+h22).T, h12)
@@ -410,7 +409,6 @@ def gradient_adagrad(self, v1, v2, h11, h12 , h21, h22):
410409
def gradient_rmsprop(self, v1, v2, h11, h12 , h21, h22):
411410
w_vh, w_v, w_h, = self.W
412411
vel_vh, vel_v, vel_h, rms_m2_vh, rms_m2_v, rms_m2_h = self.train_cache
413-
m = self.momentum
414412
rms_decay = self.rms_decay
415413
lr = self.lr
416414

@@ -495,7 +493,6 @@ def kcd_step(self, v, K):
495493

496494

497495
def pcd_step(self, v0, pv0):
498-
D = v0.sum(axis=1)
499496
h1, h2 = self.visible_to_hiddens_gibbs(v0)
500497
pv1 = self.gibbs_transition(pv0)
501498
ph1, ph2 = self.visible_to_hiddens_gibbs(pv1)
@@ -777,7 +774,7 @@ def log_ppl_upbo(self, dtm):
777774
def topic_words(self, topk, id2word=None):
778775
w_vh, w_v, w_h = self.W
779776
T = self.hidden
780-
if id2word==None:
777+
if id2word is None:
781778
id2word = self.id2word
782779
words = np.array([k for k in id2word.token2id.keys()])
783780

0 commit comments

Comments
 (0)