Changes
1 changed files (+2/-6)
-
-
@@ -29,6 +29,7 @@ class Dataset(torch.utils.data.Dataset):self.words = [word for message in text for word in message.split()] # Remove URLs and special characters and convert to lowercase self.words = [re.sub(r'[^a-z0-9]', '', word.lower()) for word in self.words if word.find('://') == -1] print(self.words[0:1000]) self.word_counts = Counter(self.words) self.uniq_words = sorted(self.word_counts, key=self.word_counts.get)
-
@@ -97,17 +98,12 @@ loss_fn = nn.CrossEntropyLoss()optimizer = torch.optim.Adam(model.parameters(), lr=1e-3) for epoch in range(1): for epoch in range(2): model.train() state_h, state_c = model.init_state(16) cnt = 0 for batch, (x, y) in enumerate(dataloader): cnt += 1 if cnt > 50: break optimizer.zero_grad() # Compute prediction error
-