Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
Create free account
hub
/
github.com/chao-ji/tf-word2vec
/ functions
Functions
52 in github.com/chao-ji/tf-word2vec
⨍
Functions
52
◇
Types & classes
7
↳
Endpoints
1
↓ 2 callers
Method
_get_inputs_syn0
Builds the activations of hidden layer given input words embeddings `syn0` and input word indices. Args: syn0: float tensor of shape [
word2vec.py:211
↓ 2 callers
Method
_get_inputs_syn0
Builds the activations of hidden layer given input words embeddings `syn0` and input word indices. Args: inputs: int tensor of shape [
tf2.x/model.py:176
↓ 1 callers
Method
_build_binary_tree
Builds a Huffman tree for hierarchical softmax. Has the side effect of setting `max_depth`. Args: unigram_counts: list of int, holding
dataset.py:121
↓ 1 callers
Method
_build_binary_tree
Builds a Huffman tree for hierarchical softmax. Has the side effect of setting `max_depth`. Args: unigram_counts: list of int, holding
tf2.x/dataset.py:147
↓ 1 callers
Method
_build_loss
Builds the graph that leads from data tensors (`inputs`, `labels`) to loss. Has the side effect of setting attribute `syn0`. Args: inpu
word2vec.py:46
↓ 1 callers
Method
_build_raw_vocab
Builds raw vocabulary. Args: filenames: list of strings, holding names of text files. Returns: raw_vocab: a list of 2-tuples ho
dataset.py:71
↓ 1 callers
Method
_build_raw_vocab
Builds raw vocabulary by iterate through the corpus once and count the unique words. Args: filenames: list of strings, holding names o
tf2.x/dataset.py:45
↓ 1 callers
Method
_create_embeddings
Creates initial word embedding variables. Args: vocab_size: int scalar, num of words in vocabulary. scope: string scalar, scope name.
word2vec.py:102
↓ 1 callers
Method
_hierarchical_softmax_loss
Builds the loss for hierarchical softmax. Args: inputs: int tensor of shape [batch_size] (skip_gram) or [batch_size, 2*window_size
word2vec.py:176
↓ 1 callers
Method
_hierarchical_softmax_loss
Builds the loss for hierarchical softmax. Args: inputs: int tensor of shape [batch_size] (skip_gram) or [batch_size, 2*window_size
tf2.x/model.py:141
↓ 1 callers
Method
_negative_sampling_loss
Builds the loss for negative sampling. Args: unigram_counts: list of int, holding word counts. Index of each entry is the same as t
word2vec.py:127
↓ 1 callers
Method
_negative_sampling_loss
Builds the loss for negative sampling. Args: inputs: int tensor of shape [batch_size] (skip_gram) or [batch_size, 2*window_size+1]
tf2.x/model.py:90
↓ 1 callers
Method
_prepare_inputs_labels
Set shape of `tensor` according to architecture and training algorithm, and split `tensor` into `inputs` and `labels`. Args: tensor: ra
dataset.py:166
↓ 1 callers
Method
build_dataset
Generates tensor dict mapping from tensor names to tensors. Args: filenames: list of strings, holding names of text files. Retur
tf2.x/dataset.py:219
↓ 1 callers
Method
build_vocab
Builds vocabulary. Has the side effect of setting the following attributes: - table_words: list of string, holding the list of vocabulary
dataset.py:91
↓ 1 callers
Method
build_vocab
Builds the vocabulary. Has the side effect of setting the following attributes: for each word `word` we have vocab[word] = index ta
tf2.x/dataset.py:71
↓ 1 callers
Method
encode
Split raw text string into tokens (space-separated) and tranlate to token ids. Args: string: string scalar, the raw text string to be
tf2.x/dataset.py:102
↓ 1 callers
Function
generate_instances
Generates matrices holding word indices to be passed to Word2Vec models for each sentence. The shape and contents of output matrices depends on the
dataset.py:314
↓ 1 callers
Function
generate_instances
Generates matrices holding word indices to be passed to Word2Vec models for each sentence. The shape and contents of output matrices depends on the
tf2.x/dataset.py:336
↓ 1 callers
Method
get_tensor_dict
Generates tensor dict mapping from tensor names to tensors. Args: filenames: list of strings, holding names of text files. Retur
dataset.py:195
↓ 1 callers
Function
get_word_indices
Converts a sentence into a list of word indices. Args: sent: a scalar string tensor, a sentence where words are space-delimited. table_word
dataset.py:279
↓ 1 callers
Method
most_similar
Finds the top-k words with smallest cosine distances w.r.t `word`. Args: word: string scalar, the query word. k: int scalar, num of w
tf2.x/word_vectors.py:29
↓ 1 callers
Function
subsample
Filters out-of-vocabulary words and then applies subsampling on words in a sentence. Words with high frequencies have lower keep probs. Args:
dataset.py:295
↓ 1 callers
Function
subsample
Filters out-of-vocabulary words and then applies subsampling on words in a sentence. Words with high frequencies have lower keep probs. Args:
tf2.x/dataset.py:317
↓ 1 callers
Method
train
Adds training related ops to the graph. Args: dataset: a `Word2VecDataset` instance. filenames: a list of strings, holding names of t
word2vec.py:73
↓ 1 callers
Function
train_step
(inputs, labels, progress)
tf2.x/run_training.py:104
Method
__contains__
(self, word)
word2vec.py:253
Method
__contains__
(self, word)
tf2.x/word_vectors.py:23
Method
__getitem__
(self, word)
word2vec.py:256
Method
__getitem__
(self, word)
tf2.x/word_vectors.py:26
Method
__init__
Constructor. Args: arch: string scalar, architecture ('skip_gram' or 'cbow'). algm: string scalar, training algorithm ('negative_samp
word2vec.py:11
Method
__init__
Constructor. Args: syn0_final: numpy array of shape [vocab_size, embed_size], final word embeddings. vocab_words: a list of s
word2vec.py:241
Method
__init__
Constructor. Args: arch: string scalar, architecture ('skip_gram' or 'cbow'). algm: string scalar: training algorithm ('negative_samp
dataset.py:17
Method
__init__
Constructor. Args: syn0_final: numpy array of shape [vocab_size, embed_size], final word embeddings. vocab: a list of strings
tf2.x/word_vectors.py:11
Method
__init__
Constructor. Args: max_vocab_size: int scalar, maximum vocabulary size. If > 0, only the top `max_vocab_size` most frequent words
tf2.x/dataset.py:18
Method
__init__
Constructor. Args: epochs: int scalar, num times the dataset is iterated. batch_size: int scalar, the returned tensors in `get_tensor
tf2.x/dataset.py:122
Method
__init__
Constructor. Args: unigram_counts: a list of ints, the counts of word tokens in the corpus. arch: string scalar, architecture ('skip
tf2.x/model.py:11
Method
call
Runs the forward pass to compute loss. Args: inputs: int tensor of shape [batch_size] (skip_gram) or [batch_size, 2*window_size+1]
tf2.x/model.py:72
Method
generator_fn
()
tf2.x/dataset.py:255
Function
get_train_step_signature
Get the training step signatures for `inputs`, `labels` and `progress` tensor. Args: arch: string scalar, architecture ('skip_gram' or 'cbow
tf2.x/utils.py:6
Method
iterator_initializer
(self)
dataset.py:60
Function
main
(_)
run_training.py:54
Function
main
(_)
tf2.x/run_training.py:58
Method
most_similar
Finds the top-k words with smallest cosine distances w.r.t `word`. Args: word: string scalar, the query word. k: int scalar, num of w
word2vec.py:259
Function
per_target_fn
(index, init_array)
dataset.py:354
Function
per_target_fn
Generate inputs and labels for each target word. `index` is the index of the target word in `indices`.
tf2.x/dataset.py:378
Method
prepare_inputs_labels
(tensor, progress)
tf2.x/dataset.py:286
Method
syn0
(self)
word2vec.py:43
Method
table_words
(self)
dataset.py:64
Method
table_words
(self)
tf2.x/dataset.py:42
Method
unigram_counts
(self)
dataset.py:68
Method
unigram_counts
(self)
tf2.x/dataset.py:38