Skip to content

Instantly share code, notes, and snippets.

@ashunigion
Created February 18, 2019 13:56
Show Gist options
  • Select an option

  • Save ashunigion/7d5dc7c0c7431339b1ec98e90a91fa16 to your computer and use it in GitHub Desktop.

Select an option

Save ashunigion/7d5dc7c0c7431339b1ec98e90a91fa16 to your computer and use it in GitHub Desktop.
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