Created
February 18, 2019 13:56
-
-
Save ashunigion/7d5dc7c0c7431339b1ec98e90a91fa16 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
| def update_input_layer(review): | |
| """ Modify the global layer_0 to represent the vector form of review. | |
| The element at a given index of layer_0 should represent | |
| how many times the given word occurs in the review. | |
| Args: | |
| review(string) - the string of the review | |
| Returns: | |
| None | |
| """ | |
| global layer_0 | |
| # clear out previous state by resetting the layer to be all 0s | |
| layer_0 *= 0 | |
| # count how many times each word is used in the given review and store the results in layer_0 | |
| for word in review.split(' '): | |
| layer_0[0,word2index[word]] += 1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment