admin管理员组文章数量:1287577
AttributeError: module 'numpy.random._pickle' has no attribute '_Forecast_model__randomstate_ctor'
I am trying to do this as I got error while loading the saved model -
model = NHiTSModel.load(model_path)
This gives me this error
"(1) In PyTorch 2.6, we changed the default value of the weights_only argument in torch.load from False to True. Re-running torch.load with weights_only set to False will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.
(2) Alternatively, to load with weights_only=True please check the recommended steps in the following error message.
WeightsUnpickler error: Unsupported global: GLOBAL numpy.random._pickle.__randomstate_ctor was not an allowed global by default. Please use torch.serialization.add_safe_globals([__randomstate_ctor]) or the torch.serialization.safe_globals([__randomstate_ctor]) context manager to allowlist this global if you trust this class/function"
class Forecast_model:
#Class to perform forecasting and scenario analysis.
def __init__(self):
#This constructor initializes the Preprocess object. It doesn't require any arguments
#and currently performs no actions.
def model_run({Arguments}):
### CODE ####
with torch.serialization.add_safe_globals([np.random._pickle.__randomstate_ctor]):
model = NHiTSModel.load(model_path, weights_only=False)
本文标签: pytorchinit function is appending the class name to quotrandomstatectorquotStack Overflow
版权声明:本文标题:pytorch - __init__ function is appending the class name to "__randomstate_ctor" - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741225366a2361757.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论