我们从Python开源项目中,提取了以下3个代码示例,用于说明如何使用keras.preprocessing.sequence.skipgrams()。
def test_skipgrams(): # test with no window size and binary labels couples, labels = skipgrams(np.arange(3), vocabulary_size=3) for couple in couples: assert couple[0] in [0, 1, 2] and couple[1] in [0, 1, 2] # test window size and categorical labels couples, labels = skipgrams(np.arange(5), vocabulary_size=5, window_size=1, categorical=True) for couple in couples: assert couple[0] - couple[1] <= 3 for l in labels: assert len(l) == 2