0

I am trying to read data using np.loadtxt and am getting a Memory error. Here is my code

 input_width = 28
 input_height = 28
 input_channels = 1
 output_dim = 2

 train = np.loadtxt("./datasets/rectangles/rectangles_train.amat")
 test = np.loadtxt("./datasets/rectangles/rectangles_test.amat")

 self.x_train = train[:, :-1]
 self.x_test = test[:, :-1]
 # Reshape images to 28x28
 self.x_train = np.reshape(self.x_train, (-1, 28, 28))
 self.x_test = np.reshape(self.x_test, (-1, 28, 28))

 self.y_train = train[:, -1]
 self.y_test = test[:, -1]

I am getting a memory error like this -

test = np.loadtxt("./datasets/rectangles/rectangles_test.amat")
File "/home/.local/lib/python3.5/site-packages/numpy/lib/npyio.py", line 1161, in loadtxt
X = np.array(x, dtype)
MemoryError: Unable to allocate 299. MiB for an array with shape (50000, 1, 785) and data type float64
molbdnilo
  • 64,751
  • 3
  • 43
  • 82
  • 1
    Does this answer your question? [Python MemoryError or ValueError in np.loadtxt and iter\_loadtxt](https://stackoverflow.com/questions/26558278/python-memoryerror-or-valueerror-in-np-loadtxt-and-iter-loadtxt) – xilpex May 08 '20 at 15:30
  • You ran out of memory. It even tells you how much it needs. – Klaus D. May 08 '20 at 15:37

0 Answers0