python - 在 Python 中加载数据集时内核死机:为什么会这样?
问题描述
我正在尝试在 Python 中加载 7000 个 .mat 文件的数据集作为 7000-d 张量,每个条目的形状为 100 x 100 x 100 x 3。整个数据集小于 80 MB。我正在使用 Spyder。代码如下
dataDir = "/Users/..."
data= []
x_train = np.empty([7165, 100*100*100*3])
x_train = x_train.reshape([7165, 100, 100, 100, 3])
i = 0;
for file in sorted_alphanumeric(os.listdir( dataDir )):
data = scipy.io.loadmat( dataDir+file ) #store data as LIST
x_train[i] = np.array(data['tensor'])
i = i + 1
然而,在读取了大约 2300 行之后,内核死了,程序停止运行。为什么内核会死?如何存储数据集?在我看来,数据集并没有那么大,控制台中的“内存”键总是在 76% 左右。
解决方案
7000x100x100x100 = 7,000,000,000 是太多的内存,即使在位 7 000 000 000 * 3 位 = 2.62500 GB中也无法处理
推荐阅读
- html - 为什么“W”字母的中间笔画在我的密码笔上非常锋利?
- c# - 如何通过单击文本框获取选项卡索引
- safari - iPadOS 13.1 的 Safari 上的 Fabric 安装程序页面未被识别为“设备”
- database - 在现有数据库上还原 Azure SQL 数据库以维护备份历史记录
- node.js - 从同一网络上的android设备请求访问服务器时,无法通过flutter应用程序连接到node.js服务器?
- java - 如何使用 Jackson 将 JSON 字段名称转换为 Java bean 类属性
- python-3.x - 从 imdb 项目 Web 抓取特定数据
- python - OpenCV warpPerspective 不适用于单应性
- http - 如何在flutter中使用curl执行https post请求
- python - 如何抑制 Python 库 TextBlob 的一些输出