Closed hhpu closed 1 month ago
您好 pred_visualization.ipynb 脚本不是用来可视化预测结果的,是用来可视化原始数据集的。 目前需要您手动保存结果并进行可视化,可以参考 Issue #64 , Issue #93 ,和 Issue #129
感谢您的回复,已解决该问题。借楼再问个让我很困扰的问题吧,关于重复实验的问题。我查看了easytorch的源代码,然后BasicTS框架中即使我在配置文件中设置了不允许cudnn使用非确定性算法,以及在train.py中也进行相应cudnn非确定算法的禁用,但是实验结果依然不可重复。
train.py文件如下: sys.path.append(os.path.abspath(file + "/../..")) import torch from basicts import launch_training
import numpy as np import random torch.set_num_threads(3) # aviod high cpu avg usage
def parse_args(): parser = ArgumentParser(description="Run time series forecasting model in BasicTS framework!") parser.add_argument("-c", "--cfg", default="baselines/STID/Electricity.py", help="training config") parser.add_argument("-g", "--gpus", default="0", help="visible gpus") return parser.parse_args()
args = parse_args()
seed =1 torch.manual_seed(seed) # args.cfg torch.cuda.manual_seed(seed) torch.cuda.manual_seed_all(seed) np.random.seed(seed) random.seed(seed) os.environ['PYTHONHASHSEED'] = str(seed)
torch.backends.cudnn.enabled = True # False torch.backends.cudnn.benchmark = False torch.backends.cudnn.deterministic = True torch.backends.deterministic = True
if name == "main":
launch_training(args.cfg, args.gpus)
baselines/STID/Electricity.py文件的 environment设置如下:
CFG.ENV = EasyDict() CFG.ENV.SEED = 1 CFG.ENV.CUDNN = EasyDict()
CFG.ENV.CUDNN.ENABLED = True # False CFG.ENV.CUDNN.BENCHMARK = False # CFG.ENV.CUDNN.DETERMINISTIC = True CFG.ENV.DETERMINISTIC = True #
请问如何复现?
固定随机数种子seed、禁用CUDNN的非确定性算法,一般就可以保证实验结果的可重复性。按理来说,basicTS框架中,在配置文件(如baselines/STID/Electricity.py)中对CFG.ENV进行相关设置,可以达到实验结果可重复的效果。我在baselines/STID/Electricity.py的environment设置部分如下,但是每次模型训练结果均不同。
CFG.ENV = EasyDict() CFG.ENV.SEED = 1 CFG.ENV.CUDNN = EasyDict() CFG.ENV.CUDNN.ENABLED = True # False # True # 修改! CFG.ENV.CUDNN.BENCHMARK = False # 修改! CFG.ENV.CUDNN.DETERMINISTIC = True # 修改! CFG.ENV.DETERMINISTIC = True # 修改!
在 2024-07-23 12:38:03,"S22" @.***> 写道:
请问如何复现?
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>
您可以参考:https://pytorch.org/docs/stable/notes/randomness.html#reproducibility
PyTorch 的随机性是一件比较复杂的事,和模型结构、实现方式、数据、软件版本都有关系,最保险的方法应该是torch.use_deterministic_algorithms(True)
,但这有可能会降低速度和性能。甚至有些算法没有确定性版本,因此有可能会报错:https://pytorch.org/docs/stable/generated/torch.use_deterministic_algorithms.html#torch.use_deterministic_algorithms
您可以参考:https://pytorch.org/docs/stable/notes/randomness.html#reproducibility
PyTorch 的随机性是一件比较复杂的事,和模型结构、实现方式、数据、软件版本都有关系,最保险的方法应该是
torch.use_deterministic_algorithms(True)
,但这有可能会降低速度和性能。甚至有些算法没有确定性版本,因此有可能会报错:https://pytorch.org/docs/stable/generated/torch.use_deterministic_algorithms.html#torch.use_deterministic_algorithms
好的,谢谢哦。by the way,祝贺邵博士顺利毕业
谢谢!XD
Dear hhpu, thank you for your attention,if BasicTS helped you, please cite this paper in your fancy works, best wishes:
[1] Shao Z, Wang F, Xu Y, et al. Exploring progress in multivariate time series forecasting: Comprehensive benchmarking and heterogeneity analysis[J]. arXiv preprint arXiv:2310.06119, 2023.
@misc{shao2023exploringprogressmultivariatetime, title={Exploring Progress in Multivariate Time Series Forecasting: Comprehensive Benchmarking and Heterogeneity Analysis}, author={Zezhi Shao and Fei Wang and Yongjun Xu and Wei Wei and Chengqing Yu and Zhao Zhang and Di Yao and Guangyin Jin and Xin Cao and Gao Cong and Christian S. Jensen and Xueqi Cheng}, year={2023}, eprint={2310.06119}, archivePrefix={arXiv}, primaryClass={cs.LG}, url={https://arxiv.org/abs/2310.06119}, }
作者您好,在pred_visualization.ipynb文件中,运行结果报错,显示 runner.test()的返回值results 为空,以至于下面plot预测结果和真实值无法进行,我是在win下运行的,请问下有没有好的解决方法?期待您的回复。