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