MCPcopy
hub / github.com/hunkim/PyTorchZeroToAll / str2tensor

Function str2tensor

13_3_char_rnn.py:48–55  ·  view source on GitHub ↗
(string)

Source from the content-addressed store, hash-verified

46
47
48def str2tensor(string):
49 tensor = [ord(c) for c in string]
50 tensor = torch.LongTensor(tensor)
51
52 if torch.cuda.is_available():
53 tensor = tensor.cuda()
54
55 return Variable(tensor)
56
57
58def generate(decoder, prime_str='A', predict_len=100, temperature=0.8):

Callers 3

generateFunction · 0.70
train_teacher_forchingFunction · 0.70
trainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected