npy文件
最近的遇到了
.npy
文件,记录一下是什么以及如何存取,其实和pkl、json、yml这种差不了太多。
npy
就是将numpy数组保存到磁盘的简单格式,二进制序列,其中包含了numpy数组的全部信息。
使用它的原因:
- A LOT faster, also notice that we didn’t need to reshape the data since that information was contained in the .npy file.(速度更快,并且存储了numpy数组的原本结构)
- Another “minor” feature of using .npy files is the reduced storage the file occupies. In this case it’s more than a 50% reduction in size. This can wary a lot though but in general the .npy files are more storage friendly.(占用内存更少)
加载npy文件,并将npy文件写入一个txt文件
import numpy as np |
保存npy文件
#显示字典 |
结构解析
import numpy as np |
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 JrunDing!
评论