Numpy dstack导致内存错误

时间:2018-05-19 03:50:28

标签: python arrays numpy

我有两个numpy形状阵列:

x.shape # (50000, 784)
y.shape # (50000,)

但是,当我使用column_stack时,我得到MemoryError

X_y = np.column_stack([X, y])
# ... MemoryError.

我希望的结果是将y作为另一列添加到X

X_y.shape # (50000, 785)

我也试过

X_y = list(zip(X, Y)) 
random.shuffle(X_y)
X, Y = zip(*X_y)
X, Y = np.array(X), np.array(Y)

它还会导致最后一行MemoryError

我遇到此错误的方式如下:

TrainX = np.loadtxt("TrainDigitX.csv.gz", delimiter=",")
TrainY = np.loadtxt("TrainDigitY.csv.gz", delimiter=",")

NN = Neural_Network((784, 30, 10))
mini_batch_size = 20
epochs = 30

for epoch in range(epochs):
    TrainX = TrainX.T.tolist()
    TrainX.append(TrainY)
    X_match_y = np.array(TrainX).T
    np.random.shuffle(X_match_y)
#... continue to run NN

0 个答案:

没有答案