简体   繁体   English

如何解决问题以重塑从 Python 中的 x_train 派生的图像中的过程?

[英]How can I fix the issue to reshape process in image derived from x_train in Python?

I found a dataset from Kaggle Here is the link: https://www.kaggle.com/quangqiyana/human-gender-identity我从 Kaggle 找到了一个数据集,这是链接: https://www.kaggle.com/quangqiyana/human-gender-identity

I want to implement CNN algorithm into dataset.我想将 CNN 算法实现到数据集中。

I wrote some codes to get X_train and Y_train我写了一些代码来获取 X_train 和 Y_train

train = pd.read_csv("files/gender.csv")
train.shape -> (230, 67502)
train.drop('Unnamed: 0', axis=1, inplace=True)
Y_train = train["Label"]
X_train = train.drop(labels = ["Label"],axis = 1) 

Then I want to show some images by iloc process然后我想通过 iloc 进程显示一些图像

img = X_train.iloc[0].to_numpy()
img = np.pad(img, (0, (67600-img.shape[0])), 'constant').reshape((260, 260))
plt.imshow(img)
plt.title(train.iloc[0,0])
plt.axis("off")
plt.show()

Because any number is not a square of 67502 , I can use pad .因为任何数字都不是67502的平方,所以我可以使用pad But the image couldn't show with resolution.但是图像无法以分辨率显示。

Here is the screenshot.这是屏幕截图。

在此处输入图像描述

How can I fix the reshape issue?如何解决重塑问题?

This dataset is likely not intended to be used with CNN, because the data encoded into the columns has no spatial relation to each other, like in images.该数据集可能不打算与 CNN 一起使用,因为编码到列中的数据彼此之间没有空间关系,就像在图像中一样。 Considering that this dataset was downloaded 1 (one) time, probably by you, and nobody has created any notebooks or deemed it worth a discussion, I'd recommend to move to another dataset, which has other people working on it, so you can ask questions there (on Kaggle) and get help.考虑到该数据集可能由您下载了 1(一次),并且没有人创建任何笔记本或认为值得讨论,我建议转移到另一个数据集,该数据集有其他人在处理它,这样您就可以在那里(在 Kaggle 上)提问并获得帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何为 LSTM keras 重塑 X_train 和 y_train - How to reshape X_train and y_train for LSTM keras 如何在主数据集中找到 X_train 索引? - How can I find X_train indexes in the main dataset? 如何通过 Python 修复 CNN 中训练和测试的重塑过程 - How to fix the reshape process of train and test in CNN via Python 如何将自定义图像数据集加载到 X_train - How to load custom image dataset to X_train 使用 Keras,如何输入 X_train 图像(超过一千张图像)? - Using Keras, how can I input an X_train of images (more than a thousand images)? 我如何 go 关于在 python 中拟合数据集? - lr.fit(x_train, y_train) 给我错误 - How do I go about fitting a dataset in python? - lr.fit(x_train, y_train) giving me errors 如何在 X_train、y_train、X_test、y_test 中拆分图像数据集? - How to split an image dataset in X_train, y_train, X_test, y_test? 这种python索引如何工作:'print(X_train [y_train == 0] [0])'在python中工作? - how does this sort of python indexing: 'print(X_train[y_train == 0][0])' work in python? 如何使用带有 x_train 和 y_train 变量的神经网络的 python 生成器? - How to use python generators with neural networks that take in data with x_train and y_train variables? X_train, y_train 来自转换后的数据 - X_train, y_train from transformed data
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM