python - 如何将图像和标签的 numpy 数组保存为 tar.gz 或 idx3-ubyte.gz?
问题描述
基本上我试图弄清楚如何以有效的格式存储我的机器学习图像数据集。现在,我想出了如何将我的训练图像、测试图像和标签保存为 .npz 文件中的 numpy 数组,但我希望弄清楚如何以 mnist 数据库的样式存储图像。我的图像尺寸为(128、128)并且有 3 个颜色通道。有没有办法将我的图像数据转换为更好的格式并 gzip 进行压缩?谢谢你。
这是我目前存储我收集的 11,500 张图像的方式。
import numpy as np
def load_data():
print("Loading Recycle Data")
path = 'recycle_data_shuffled.npz'
recycle_data = np.load(path)
x_train, y_train = recycle_data['x_train'], recycle_data['y_train']
x_test, y_test = recycle_data['x_test'], recycle_data['y_test']
recycle_data.close()
return (x_train, y_train), (x_test, y_test)
解决方案
推荐阅读
- html - 禁用 Chrome 自动填充弹出窗口
- c - 为什么 if 语句的这一部分不起作用?
- c# - 使用 docker compose 时如何修复“设置 DOTNET_USER_SECRETS_FALLBACK_DIR”错误?
- excel - 在excel中解决一个复杂的矩阵问题
- c - 为什么我的程序中的矩阵乘法会崩溃?
- javascript - ExtJS 6 - 带有 inputType 'password' 的文本字段在 Chrome 开发工具中生成警告
- amazon-web-services - 如何在 cloudformation 中创建托管策略,允许 lambda 访问 aws 环境中的所有 s3 容器
- azure - 为什么我的消息总是传递到 Azure 服务总线中的死信队列?
- java - ModelMapper:自定义 PropertyMap 抛出 NullPointer 异常
- compression - 如何使用 PyArrow 压缩/解压缩序列化的 Pandas 数据帧?