Changes
1 changed files (+11/-3)
-
-
@@ -25,7 +25,7 @@ statuses = cur.fetchall()# Extract all words from statuses # Use regex to remove HTML stuff text = [re.sub(r'<[^>]*>', '', status[2]) for status in statuses] text = [re.sub(r'<[^>]*>', ' ', status[2]) for status in statuses] # print(text[0:100])
-
@@ -35,6 +35,8 @@ 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] # Remove empty strings self.words = [word for word in self.words if word != ''] print(self.words[0:1000]) self.word_counts = Counter(self.words)
-
@@ -68,8 +70,8 @@ class Model(nn.Module):def __init__(self, dataset): super(Model, self).__init__() self.lstm_size = 128 self.embedding_dim = 128 self.lstm_size = 512 self.embedding_dim = 512 self.num_layers = 3 n_vocab = len(dataset.uniq_words)
-
@@ -109,7 +111,13 @@ for epoch in range(2):state_h, state_c = model.init_state(16) cnt = 0 for batch, (x, y) in enumerate(dataloader): cnt += 1 if cnt > 100: break optimizer.zero_grad() # Compute prediction error
-