我对keras.preprocessing.sequence中的skipgram函数有疑问。
在规范link中,skipgrams函数使用字典生成负样本。
要了解跳报,请打印跳报功能的结果。
我注意到结果有矛盾,正样本和负样本两边都成对。
这些数据对模型没有影响吗?
或
大词典可以忽略这些冲突吗?
我的代码如下:
samplingTable = keras.preprocessing.sequence.make_sampling_table(26)
print (samplingTable)
targetList = [random.randint(0,25) for i in range(200)]
couple, labels = keras.preprocessing.sequence.skipgrams(targetList, 26, sampling_table=samplingTable,shuffle=False )
result= []
for i in range(len(labels)):
result.append("{}\t{}\t{}".format(couple[i][0],couple[i][1],labels[i]))
for i in sorted(result):
print (i)
和以下是代码的结果。 (8,24),(8,25)发生冲突。 (正 1和负0)
target context isExist
8 1 1
8 10 0
8 10 0
8 11 1
8 12 0
8 14 0
8 2 1
8 24 0
8 24 1
8 25 0
8 25 1