0

I have a Python code, I get the following error when executing:

m_f = np.zeros((len(docs_f), len(vocab)))

MemoryError: Unable to allocate array with shape (53972, 215413) and data type float64

Looks like I have a memory problem. I'm using a Windows 10 system with 16GB of RAM, can anyone work out a solution to my problem?

Kostas Charitidis
  • 2,991
  • 1
  • 12
  • 23
Siamak Abdi
  • 191
  • 1
  • 1
  • 10
  • Possible duplicate of [Memory errors and list limits?](https://stackoverflow.com/questions/5537618/memory-errors-and-list-limits) – Julien Kieffer Oct 24 '19 at 06:55
  • 3
    A single `float64` needs `64` bits or `8` byte of memory. Now, you have `53972 x 215413 x 8` byte, which is around 87 GB of memory. The solution to your problem is, as always, buy more RAM. :-) – HansHirse Oct 24 '19 at 06:56
  • 1
    No problem with the `python` code. You will need to post a new question with what you eventually want to achieve in the program, stating that creating such a `numpy array` is not possible, and maybe someone would find a more memory-efficient way to achieve it. – Aryerez Oct 24 '19 at 06:57
  • Choose another data type (https://docs.scipy.org/doc/numpy/user/basics.types.html), int32 or even int16 could be more appropriated (87 GB of RAM seems... a lot) – HGLR Oct 24 '19 at 08:17

0 Answers0