Skip to content

Instantly share code, notes, and snippets.

@morenoh149
Created July 21, 2018 23:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morenoh149/b164e48a35fe4e6df1f85c4d5b054e70 to your computer and use it in GitHub Desktop.
Save morenoh149/b164e48a35fe4e6df1f85c4d5b054e70 to your computer and use it in GitHub Desktop.
---------------------------------------------------------------------------
MemoryError Traceback (most recent call last)
<ipython-input-22-567222df1eb0> in <module>()
----> 1 x_train = vectorize_sequences(train_data)
2 x_test = vectorize_sequences(test_data)
<ipython-input-21-5d7c33381575> in vectorize_sequences(sequences, dimension)
2 # are a 1 in the tensor, 0 otherwise
3 def vectorize_sequences(sequences, dimension=10000):
----> 4 results = np.zeros((len(sequences), dimension))
5 for i, sequence in enumerate(sequences):
6 results[i, sequence] = 1.
MemoryError:
# accepts sequences list/nparray and returns a tensor where those numbers
# are a 1 in the tensor, 0 otherwise
def vectorize_sequences(sequences, dimension=10000):
results = np.zeros((len(sequences), dimension))
for i, sequence in enumerate(sequences):
results[i, sequence] = 1.
return results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment