I have two large NumPy arrays and need to concatenate them, but NumPy function 'concatenate' eats up almost all of my memory, so I can't do anything further. And I was trying this variant:
X = np.zeros((x.shape[0], discourse_type.shape[-1]+x.shape[-1]))
for i in range(X.shape[0]):
X[i][:x.shape[-1]] = x[i][0]
X[i][x.shape[-1]:] = discourse_type[i][0]
But this variant also eats up almost all of my memory. So, maybe I can concatenate without consuming nearly all of the memory?
So, what I have done before:
vectorizer = CountVectorizer()
x = vectorizer.fit_transform(train['discourse_text'])
x = x.toarray()[:,np.newaxis,:]
shape = x.shape[-1]
def str_to_numeric(df, column):
y = np.zeros((len(df.index), len(df[column].unique())))
dict_types = {df[column].unique()[i]:i for i in range(len(df[column].unique()))}
for i in df.index:
y[i][dict_types[df[column][i]]] = 1
return np.array(y)
discourse_type = str_to_numeric(train, 'discourse_type')[:, np.newaxis, :]
y = str_to_numeric(train, 'discourse_effectiveness')
# X = np.concatenate((discourse_type, x), axis=-1)
X = np.zeros((x.shape[0], discourse_type.shape[-1]+x.shape[-1]))
for i in range(X.shape[0]):
X[i][:x.shape[-1]] = x[i][0]
X[i][x.shape[-1]:] = discourse_type[i][0]
Maybe there is another variant to do something before?