(string)
| 46 | |
| 47 | |
| 48 | def 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 | |
| 58 | def generate(decoder, prime_str='A', predict_len=100, temperature=0.8): |
no outgoing calls
no test coverage detected