MCPcopy Create free account
hub / github.com/pytorch/tutorials / inputTensor

Function inputTensor

intermediate_source/char_rnn_generation_tutorial.py:235–240  ·  view source on GitHub ↗
(line)

Source from the content-addressed store, hash-verified

233
234# One-hot matrix of first to last letters (not including EOS) for input
235def inputTensor(line):
236 tensor = torch.zeros(len(line), 1, n_letters)
237 for li in range(len(line)):
238 letter = line[li]
239 tensor[li][0][all_letters.find(letter)] = 1
240 return tensor
241
242# ``LongTensor`` of second letter to end (EOS) for target
243def targetTensor(line):

Callers 2

randomTrainingExampleFunction · 0.85
sampleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected