|
7 | 7 |
|
8 | 8 |
|
9 | 9 | ###################################################################### |
| 10 | +# This example requires PyTorch 1.0 (preview) or later. For installation |
| 11 | +# information visit http://pytorch.org/get-started. |
| 12 | +# |
10 | 13 | # This tutorial will walk through the process of transitioning a |
11 | 14 | # sequence-to-sequence model to Torch Script using PyTorch’s Hybrid |
12 | 15 | # Frontend. The model that we will convert is the chatbot model from the |
13 | | -# `Chatbot tutorial <>`__. While the `introductory hybrid frontend |
14 | | -# tutorials <>`__ are useful for gaining an understanding of the |
15 | | -# work-flow, purpose, and basic syntax of the feature, this document |
16 | | -# covers a more challenging model and a more practical use-case. You can |
17 | | -# either treat this tutorial as a “Part 2” to the `Chatbot tutorial <>`__ |
| 16 | +# `Chatbot tutorial <https://pytorch.org/tutorials/beginner/chatbot_tutorial.html>`__. |
| 17 | +# You can either treat this tutorial as a “Part 2” to the Chatbot tutorial |
18 | 18 | # and deploy your own pretrained model, or you can start with this |
19 | 19 | # document and use a pretrained model that we host. In the latter case, |
20 | | -# you can reference the original `Chatbot tutorial <>`__ for details |
| 20 | +# you can reference the original Chatbot tutorial for details |
21 | 21 | # regarding data preprocessing, model theory and definition, and model |
22 | 22 | # training. |
23 | 23 | # |
|
117 | 117 | import unicodedata |
118 | 118 | import numpy as np |
119 | 119 |
|
120 | | - |
121 | | -USE_CUDA = torch.cuda.is_available() |
122 | 120 | device = torch.device("cpu") |
123 | 121 |
|
| 122 | + |
124 | 123 | MAX_LENGTH = 10 # Maximum sentence length |
125 | 124 |
|
126 | 125 | # Default word tokens |
@@ -728,10 +727,9 @@ def evaluateExample(sentence, encoder, decoder, searcher, voc): |
728 | 727 | dropout = 0.1 |
729 | 728 | batch_size = 64 |
730 | 729 |
|
| 730 | +# If you're loading your own model |
731 | 731 | # Set checkpoint to load from |
732 | 732 | checkpoint_iter = 4000 |
733 | | - |
734 | | -# If you're loading your own model |
735 | 733 | # loadFilename = os.path.join(save_dir, model_name, corpus_name, |
736 | 734 | # '{}-{}_{}'.format(encoder_n_layers, decoder_n_layers, hidden_size), |
737 | 735 | # '{}_checkpoint.tar'.format(checkpoint_iter)) |
|
0 commit comments