Skip to content

Commit e0cd4dd

Browse files
committed
refactoring: Deduplication
1 parent 8ee2bf8 commit e0cd4dd

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

tensorlayer/layers/embedding.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,8 @@ def forward(self, inputs, use_nce_loss=None):
284284
The nce_cost is returned only if the nce_loss is used.
285285
"""
286286

287-
if isinstance(inputs, list):
288-
outputs = tf.nn.embedding_lookup(params=self.embeddings, ids=inputs[0])
289-
else:
290-
outputs = tf.nn.embedding_lookup(params=self.embeddings, ids=inputs)
287+
ids = inputs[0] if isinstance(inputs, list) else inputs
288+
outputs = tf.nn.embedding_lookup(params=self.embeddings, ids=ids)
291289

292290
if use_nce_loss is True and not self.activate_nce_loss:
293291
raise AttributeError(

0 commit comments

Comments
 (0)