Update nano_gpt_inferencing.py
Browse files- nano_gpt_inferencing.py +4 -4
nano_gpt_inferencing.py
CHANGED
@@ -22,12 +22,12 @@ dropout = 0.2
|
|
22 |
torch.manual_seed(1337)
|
23 |
|
24 |
# wget https://raw.githubusercontent.com/karpathy/char-rnn/master/data/tinyshakespeare/input.txt
|
25 |
-
|
26 |
-
|
27 |
|
28 |
# here are all the unique characters that occur in this text
|
29 |
-
|
30 |
-
|
31 |
# create a mapping from characters to integers
|
32 |
stoi = { ch:i for i,ch in enumerate(chars) }
|
33 |
itos = { i:ch for i,ch in enumerate(chars) }
|
|
|
22 |
torch.manual_seed(1337)
|
23 |
|
24 |
# wget https://raw.githubusercontent.com/karpathy/char-rnn/master/data/tinyshakespeare/input.txt
|
25 |
+
with open('input.txt', 'r', encoding='utf-8') as f:
|
26 |
+
text = f.read()
|
27 |
|
28 |
# here are all the unique characters that occur in this text
|
29 |
+
chars = sorted(list(set(text)))
|
30 |
+
vocab_size = len(chars)
|
31 |
# create a mapping from characters to integers
|
32 |
stoi = { ch:i for i,ch in enumerate(chars) }
|
33 |
itos = { i:ch for i,ch in enumerate(chars) }
|