如何将不规则张量保存为文件?
如何将参差不齐张量作为文件保存在磁盘上,然后在从磁盘打开它的计算中重复使用它?张量由一个嵌套的数字数组组成,点后有 4 个符号。 (我在 Google Colab 工作并使用 Google 磁盘保存我的文件,我只懂一点 Python)。
这是我的数据: 我采用这一列“sim_fasttex”,它是不同长度的列表的列表,根据“h”和“w”重塑每个列表,并将所有这些矩阵收集在一个列表中,所以最终它将成为形状(初始表中的行数、矩阵的可变长度、矩阵的可变高度)
How can I save a ragged tensor as a file on my disk and then reuse it in calculations opening it from the disk? Tensor consists of a nested array of numbers with 4 signs after the point. (I'm working in a Google Colab and using Google disk to save my files, I know only Python a little bit).
Here is my data:
I take this column "sim_fasttex" which is a list of lists of different length, reshape each of them according to "h" and "w" and collect all these matrices in one list, so finally it's going to be a ragged tensor of the shape (number of rows in initial table, variable length of a matrix, variable heigth of a matrix)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道您的上下文,但是
您可以使用
pickle
模块将任何对象保存到文件中。像这样稍后你可以加载同一个对象:
I don't know your context but,
You can save any object to a file using the
pickle
module. Like thisAnd later you can load that same object: