hYk
hYk

Reputation: 789

'MemoryError' when padding sequences using tensorflow

I am trying to training my model on an AWS instance 'g2.2xlarge' but getting a 'MemoryError' when trying to add paddings to my sequences.

content_array = keras.preprocessing.sequence.pad_sequences(content_array, maxlen=max_sequence_length,
                                                              padding='post')

Getting this error:

Traceback (most recent call last):
  File "trainer.py", line 185, in <module>
    train()
  File "trainer.py", line 52, in train
    padding='post')
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/keras/preprocessing/sequence.py", line 94, in pad_sequences
    x = (np.ones((num_samples, maxlen) + sample_shape) * value).astype(dtype)
MemoryError

Any idea why ? I haven't started training the model even.

Upvotes: 0

Views: 839

Answers (1)

hYk
hYk

Reputation: 789

I was calculating the maximum sequence length incorrectly which led to a huge number. After correcting it I am not having any issues.

Upvotes: 2

Related Questions