Last active
February 23, 2019 04:57
-
-
Save ashunigion/80c2a51c8778fc90f5fc411b2ec1e8b2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # we create a list of the indices of words in vocabulary as the input to network | |
| training_reviews = [] | |
| for review in training_reviews_raw: | |
| indices = set() | |
| for word in review.split(" "): | |
| if word in word2index.keys(): | |
| indices.add(self.word2index[word]) | |
| training_reviews.append(list(indices)) | |
| # forward pass for each data point in the batch(index i) | |
| self.layer_1 *= 0 | |
| for index in review: | |
| self.layer_1 += self.weights_0_1[index] | |
| output = self.sigmoid(np.dot(self.layer_1,self.weights_1_2)) | |
| # weight updates for each data point in the batch(index i) | |
| self.weights_1_2 += (self.learning_rate)*np.dot(self.layer_1.T,output_error_term) | |
| for index in training_reviews[i]: | |
| self.weights_0_1[index] += (self.learning_rate)*(hidden_error_term[0]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment