MCPcopy Create free account
hub / github.com/lazyprogrammer/machine_learning_examples / vectorize_stories

Function vectorize_stories

nlp_class3/memory_network.py:123–133  ·  view source on GitHub ↗
(data, word2idx, story_maxlen, query_maxlen)

Source from the content-addressed store, hash-verified

121# we will need to re-pad the stories later so that each story
122# is the same length
123def vectorize_stories(data, word2idx, story_maxlen, query_maxlen):
124 inputs, queries, answers = [], [], []
125 for story, query, answer in data:
126 inputs.append([[word2idx[w] for w in s] for s in story])
127 queries.append([word2idx[w] for w in query])
128 answers.append([word2idx[answer]])
129 return (
130 [pad_sequences(x, maxlen=story_maxlen) for x in inputs],
131 pad_sequences(queries, maxlen=query_maxlen),
132 np.array(answers)
133 )
134
135
136

Callers 1

get_dataFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected