python-3.x - FileNotFoundError: [Errno2] | Python, using NumPy save and load
问题描述
So here is my code that saves an array and later loads it so i can sum all the arrays, it works just fine, it creates the folder and the file itself, it saves and then loads the file and completes the task. ( 1st image ). Do you have any other idea how can i get this done without saving to an external file ?
Here is another code in the same project using the same numpy.save technique and it does not run, i tried a lot to find a solution, i used the exact path and had the same error ( 2nd image)
Do you have any idea how can i fix this ? It drives me crazy!
Thank you in advance!
解决方案
关于您关于保存/加载数组的更有效方法的第一个问题,我建议在循环外声明一个列表,并将每次迭代创建的新数组附加到该列表中。您可以稍后在另一个循环中访问此列表中的项目以将它们添加(或您想做的任何其他事情......)。
以下是这种技术的说明性使用:
stack = []
for i in range(N):
temp = numpy.random.rand(dim, dim)
stack.append(temp)
我用来numpy
为二维数组生成随机值……这与示例无关。关键是定义列表并将在循环中创建的临时stack
数组附加到它。temp
由于您的数组似乎是完整的浮点数组,因此您也可以转换stack
为 numpy 数组以更快地访问 - 然后它变成一个 (2+1)D 数组。不过,这取决于你。
告诉我我是否打对了位置。谢谢!
推荐阅读
- azure - Azure 持久计时器练习永远不会超时
- common-lisp - 声明检查类型之间的 Common Lisp 区别
- function - 自定义 max_pool 层:ValueError:应定义输入的通道维度。找到`无`
- angular - TypeScript 区分大小写吗?
- amazon-web-services - 如何阻止 s3fs 删除添加到已安装 S3 存储桶的文件
- java - java.sql.Date 不能表示 12-31-2019 而不增加年份
- python-3.x - 在 Python 包中存储 api 调用所需的 XML 的最佳方式
- excel - 可以在 windows docker 容器中使用 excel 吗?
- vb6 - FFProbe 不会将结果输出到文件
- python - 在 xlsxwriter 中传递一个变量以进行 pandas 条件格式