如何删除nd.array中的元素?

时间:2019-05-23 08:01:18

标签: python numpy numpy-ndarray

我是CNN(文本)的新手

我有2个ndarray,具有3个维度。

我想将元素train_input.shape[1] = 137更改为100。

但是,当我放置100而不是元素train_input.shape[1] = 137时,会出错。

如何操作?

from sklearn.model_selection import train_test_split


test_data_size = count_test
train_data_size = count_train
print(train_data_size,'',test_data_size)


train_input = title_vector_arr[0:train_data_size]
train_label = ctr_class_arr[0:train_data_size]
test_input = title_vector_arr[train_data_size:]
test_label = ctr_class_arr[train_data_size:]
train_input = np.array(train_input)
train_input = train_input.reshape(train_input.shape[0], #6307
                                 train_input.shape[1], #137 
                                 VECTOR_SIZE) #300


test_input = np.array(test_input)
test_input = test_input.reshape(test_input.shape[0], #1000
                                 test_input.shape[1], #137
                                 VECTOR_SIZE) #300
train_input = np.array(train_input)
train_input = train_input.reshape(train_input.shape[0],100, VECTOR_SIZE)
test_input = np.array(test_input)
test_input = test_input.reshape(test_input.shape[0],100, VECTOR_SIZE)
---------------------------------------------------------------------------
MemoryError                               Traceback (most recent call last)
<ipython-input-63-d4d85efe9179> in <module>
----> 1 train_input = np.array(train_input)
      2 train_input = train_input.reshape(train_input.shape[0],100, VECTOR_SIZE)
      3 test_input = np.array(test_input)
      4 test_input = test_input.reshape(test_input.shape[0],100, VECTOR_SIZE)

MemoryError:

0 个答案:

没有答案