Spec-Zone.ru › TensorFlow 2.3

tf.keras.preprocessing.sequence.skipgrams

Генерирует пары слов skipgram.

Просмотр псевдонимов

Псевдонимы для миграции

См. Руководство по миграции для получения дополнительных сведений.

tf.compat.v1.keras.preprocessing.sequence.skipgrams

tf.keras.preprocessing.sequence.skipgrams(
    sequence, vocabulary_size, window_size=4, negative_samples=1.0, shuffle=True,
    categorical=False, sampling_table=None, seed=None
)

Эта функция преобразует последовательность индексов слов (список целых чисел) в кортежи слов следующего вида:

  • (слово, слово в том же окне), с меткой 1 (положительные примеры).
  • (слово, случайное слово из словаря), с меткой 0 (отрицательные примеры).

Подробнее о Skipgram в этой работе Миколова и др.: Эффективная оценка представлений слов в векторном пространстве

Аргументы

sequence: A word sequence (sentence), encoded as a list
    of word indices (integers). If using a `sampling_table`,
    word indices are expected to match the rank
    of the words in a reference dataset (e.g. 10 would encode
    the 10-th most frequently occurring token).
    Note that index 0 is expected to be a non-word and will be skipped.
vocabulary_size: Int, maximum possible word index + 1
window_size: Int, size of sampling windows (technically half-window).
    The window of a word `w_i` will be
    `[i - window_size, i + window_size+1]`.
negative_samples: Float >= 0. 0 for no negative (i.e. random) samples.
    1 for same number as positive samples.
shuffle: Whether to shuffle the word couples before returning them.
categorical: bool. if False, labels will be
    integers (eg. `[0, 1, 1 .. ]`),
    if `True`, labels will be categorical, e.g.
    `[[1,0],[0,1],[0,1] .. ]`.
sampling_table: 1D array of size `vocabulary_size` where the entry i
    encodes the probability to sample a word of rank i.
seed: Random seed.

Возвращаемые значения

couples, labels: where `couples` are int pairs and
    `labels` are either 0 or 1.

Примечание

By convention, index 0 in the vocabulary is
a non-word and will be skipped.

© 2020 The TensorFlow Authors. All rights reserved.
Licensed under the Creative Commons Attribution License 3.0.
Code samples licensed under the Apache 2.0 License.
https://www.tensorflow.org/versions/r2.3/api_docs/python/tf/keras/preprocessing/sequence/skipgrams

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API