MCPcopy Index your code
hub / github.com/pytorch/tutorials / letterToIndex

Function letterToIndex

intermediate_source/char_rnn_classification_tutorial.py:123–128  ·  view source on GitHub ↗
(letter)

Source from the content-addressed store, hash-verified

121
122# Find letter index from all_letters, e.g. "a" = 0
123def letterToIndex(letter):
124 # return our out-of-vocabulary character if we encounter a letter unknown to our model
125 if letter not in allowed_characters:
126 return allowed_characters.find("_")
127 else:
128 return allowed_characters.find(letter)
129
130# Turn a line into a <line_length x 1 x n_letters>,
131# or an array of one-hot letter vectors

Callers 1

lineToTensorFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected