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

Function str2tensor

seq2seq_models.py:26–31  ·  view source on GitHub ↗
(msg, eos=False)

Source from the content-addressed store, hash-verified

24
25# Sting to char tensor
26def str2tensor(msg, eos=False):
27 tensor = [ord(c) for c in msg]
28 if eos:
29 tensor.append(EOS_token)
30
31 return cuda_variable(torch.LongTensor(tensor))
32
33
34# To demonstrate seq2seq, We don't handle batch in the code,

Callers 5

trainFunction · 0.90
translateFunction · 0.90
testFunction · 0.90
trainFunction · 0.90
translateFunction · 0.90

Calls 1

cuda_variableFunction · 0.85

Tested by

no test coverage detected