MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / get_word_index

Function get_word_index

sentiment/python/imdb.py:43–56  ·  view source on GitHub ↗

Get word index. Args: reverse: Reverse the index, so that the returned index is from index values to words. Returns: The word index as a `dict`.

(reverse=False)

Source from the content-addressed store, hash-verified

41
42
43def get_word_index(reverse=False):
44 """Get word index.
45
46 Args:
47 reverse: Reverse the index, so that the returned index is from index values
48 to words.
49
50 Returns:
51 The word index as a `dict`.
52 """
53 word_index = tf.keras.datasets.imdb.get_word_index()
54 if reverse:
55 word_index = dict((word_index[key], key) for key in word_index)
56 return word_index
57
58
59def indices_to_words(reverse_index, indices):

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected