如何使用“将(120100100)形状的图像数据重塑为(12010000)形状,使其低于采样?”;“学习”;Python库?

如何使用“将(120100100)形状的图像数据重塑为(12010000)形状,使其低于采样?”;“学习”;Python库?,python,imbalanced-data,imblearn,Python,Imbalanced Data,Imblearn,我正在使用IMBRearnPython库进行欠采样 必要代码: undersample = RandomUnderSampler(sampling_strategy='majority') X_under, y_under = undersample.fit_resample(X, y) 这里X是我的图像数据集,(120100100)形状的和y是图像的标签,它是(120,)形状的。我这里有个错误。 但是如果我给出X的形状(X\u值,y\u值),那么它就工作了。 有什么方法可以将图像数据的(12

我正在使用IMBRearnPython库进行欠采样

必要代码:

undersample = RandomUnderSampler(sampling_strategy='majority')
X_under, y_under = undersample.fit_resample(X, y)
这里X是我的图像数据集,(120100100)形状的y是图像的标签,它是(120,)形状的。我这里有个错误。 但是如果我给出X形状(X\u值,y\u值),那么它就工作了。
有什么方法可以将图像数据的(120100100)形状转换为(12010000)形状吗?

将图像数据转换为一个numpy数组,然后再进行整形,这将解决问题

import numpy as np
# assuming X is the image data of shape (120,100,100)
X = np.asarray(image)
X_reshape = X.reshape(120,10000) 

你也应该把你的问题重新定义为如何重塑,而不是如何取消取样,因为这就是问题所在。