From 18586c9c6db7fbc181fe12948f95c17b62f26903 Mon Sep 17 00:00:00 2001 From: h00Jiang <378213564@qq.com> Date: Wed, 29 Aug 2018 14:08:29 +0800 Subject: [PATCH] fix a bug (when init_emb is not None , get an error) --- fastNLP/modules/encoder/embedding.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fastNLP/modules/encoder/embedding.py b/fastNLP/modules/encoder/embedding.py index b2641bff..73ddd77a 100644 --- a/fastNLP/modules/encoder/embedding.py +++ b/fastNLP/modules/encoder/embedding.py @@ -15,7 +15,7 @@ class Embedding(nn.Module): def __init__(self, nums, dims, padding_idx=0, sparse=False, init_emb=None, dropout=0.0): super(Embedding, self).__init__() self.embed = nn.Embedding(nums, dims, padding_idx, sparse=sparse) - if init_emb: + if init_emb is not None: self.embed.weight = nn.Parameter(init_emb) self.dropout = nn.Dropout(dropout)