-
Notifications
You must be signed in to change notification settings - Fork 84
Open
Description
您的keras版本config中词汇表的大小设置的是10000,因为在您给的pkl文件中dict['<s>']=0,dict['</s>']=0,dict['UNK']=1
其实<s> </s>是相同的,所以len=10000+1
keras版本
convert函数中 return [vocab.get(w, 0) for w in words]在将本文转换为数字的时候,您将unk默认值设置为0,但是pkl中unk是1阿。
而且您的 return pad_sequences(data, maxlen=len, padding='post', truncating='post', value=0)中填充的是0,在pkl中是和是为0的,与pad的意义是否相符阿?,这里是不是存在问题阿。我刚接触nlp不久,不知道我的理解是不是对的。
在我的立即填充应该是pad标识符,就是您pytorch版本中的数据pad=0,<s>=1,</s>=2,<unk>=3,这里的pad就是0。与json数据相符。
关于keras版本的数据我在做将文本转换为数字的数据时(因为文本—>数字映射——>pkl)
dict['<s>']=0,dict['</s>']=0,dict['UNK']=1,我这么改下面的函数合理么?
(1)return [vocab.get(w, 1) for w in words],将默认从vocab.get(w, 0)改成vocab.get(w, 1)
(2)return pad_sequences(data, maxlen=len, padding='post', truncating='post', value=0),这里认为pad填充的就是<s>,</s>?
Metadata
Metadata
Assignees
Labels
No labels