复制
收藏
提问
简洁

D:\sll\VALIDATIONZ\eval.py:20: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.

5ddb9a101
3周前
全网
文档
学术
百科
知识库
时间不限
自动
回答简洁模式
深入研究一些
  • 警告信息指出,使用 torch.load 时默认的 weights_only=False 将在未来版本中更改为 True

torch.load 使用警告

  • 默认值变更weights_only 参数的默认值将从 False 变为 True,以提高安全性。1
  • 安全风险:当前默认值可能允许恶意 pickle 数据在反序列化时执行任意代码。1
  • 推荐操作:如果对加载的文件没有完全控制,建议开始设置 weights_only=True1
  • 反馈问题:对于这个实验性特性有任何问题,建议在 GitHub 上提出 issue。1
你觉得结果怎么样?
如何提高Python代码的安全性?
PyTorch模型加载的最佳实践是什么?
如何使用PyTorch进行深度学习模型的部署?
torch.load默认值变更的影响是什么?
如何设置torch.load的weights_only参数?
使用torch.load加载模型时应注意哪些安全风险?

以上内容由AI搜集生成,仅供参考

在线客服