close

[Fixed] numpy.core._exceptions.MemoryError: Unable to allocate array with shape

Today We are Going To Solve numpy.core._exceptions.MemoryError: Unable to allocate array with shape in Python. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.

How to Fix numpy.core._exceptions.MemoryError: Unable to allocate array with shape Error?

  1. How to Fix numpy.core._exceptions.MemoryError: Unable to allocate array with shape Error?

    To Fix numpy.core._exceptions.MemoryError: Unable to allocate array with shape Error just Change dtype to uint8. Here you can solve this error by just changing dtype to uint8. from mask = nmp.zeros(edges.shape) to mask = nmp.zeros(edges.shape,dtype='uint8') And your error will be removed.

  2. numpy.core._exceptions.MemoryError: Unable to allocate array with shape

    To Fix numpy.core._exceptions.MemoryError: Unable to allocate array with shape Error just Change your data type. Just change your data type to numpy.uint8 just like below and your error will be removed. data['label'] = data['label'].astype(np.uint8)

Solution 1 : Change dtype to uint8

Here you can solve this error by just changing dtype to uint8.

from

mask = nmp.zeros(edges.shape)

to

mask = nmp.zeros(edges.shape,dtype='uint8')

And your error will be removed.

Solution 2 : Change your data type

Just change your data type to numpy.uint8 just like below and your error will be removed.

data['label'] = data['label'].astype(np.uint8)

Conclusion

So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.

Also Read This Solutions

Leave a Comment