DAMO-DI-ML / NeurIPS2023-One-Fits-All

The official code for "One Fits All: Power General Time Series Analysis by Pretrained LM (NeurIPS 2023 Spotlight)"
470 stars 66 forks source link

运行短期预测时报错 #34

Open licx11 opened 7 months ago

licx11 commented 7 months ago

因为网络原因,我本地下载了gpt2模型,并修改了原代码中GPT4TS.py 36行处: self.gpt2 = GPT2Model.from_pretrained('gpt2', output_attentions=True, output_hidden_states=True)self.gpt2 = AutoModelForCausalLM.from_pretrained("/***/models--openai-community--gpt2/snapshots/607a30d783dfa663caf39e06633721c8d4cfcd7e", output_attentions=True, output_hidden_states=True) 然后在运行脚本时遇到问题: self.gpt2.h = self.gpt2.h[:configs.gpt_layers]处报错 AttributeError: 'GPT2LMHeadModel' object has no attribute 'h'

PSacfc commented 7 months ago

可以看一下源码https://github.com/huggingface/transformers/blob/main/src/transformers/models/gpt2/modeling_gpt2.py 与使用方式,GPT2LMHeadModel的一个变量transformer是GPT2Model