thuml / Large-Time-Series-Model

Official code, datasets and checkpoints for "Timer: Generative Pre-trained Transformers Are Large Time Series Models" (ICML 2024)
https://arxiv.org/abs/2402.02368
MIT License
332 stars 28 forks source link

loading fine tuned model #10

Closed dialuser closed 3 weeks ago

dialuser commented 3 months ago

Hi,

I fine tuned model by setting args.is_finetuning to 1. Then I tried to do testing only by loading the saved fine tuned model, which is saved under checkpoints/[modelstring]/checkpoint.pth. However, the current code in Timer's init() didn't work. It tried to load model.backbone weights from pth.

        if self.ckpt_path != '':
            if self.ckpt_path == 'random':
                print('loading model randomly')
            else:
                print('loading model: ', self.ckpt_path)
                if self.ckpt_path.endswith('.pth'):
                    self.backbone.load_state_dict(torch.load(self.ckpt_path))

Why not load the model weights for the entire Timer model? Did I do this correctly?

Thanks

ZDandsomSP commented 3 months ago

Hello, this situation is due to us encapsulating the pre trained Timer with a layer of code called TimerBackbone.py. The instance of Timer will use the module of self.backbone in its member variable, which is equivalent to directly using Timer. Therefore, this layer of encapsulation does not affect the actual functionality.