cure-lab / SCINet

The GitHub repository for the paper: “Time Series is a Special Sequence: Forecasting with Sample Convolution and Interaction“. (NeurIPS 2022)
Apache License 2.0
617 stars 127 forks source link

如何获得模型的FLOPS、Params等参数信息? #39

Closed DomineeringDragon closed 2 years ago

DomineeringDragon commented 2 years ago

相比于MSE、MAE等数据,我还想比较这个模型和其他TSF模型的不同,比如FLOPS和params。请问有办法获得SCINet的这些信息吗?

ailingzengzzz commented 2 years ago

Hi @DomineeringDragon ,

You can use the below code after defining the model:

from ptflops import get_model_complexity_info    
with torch.cuda.device(0):
    macs, params = get_model_complexity_info(model.cuda(), (101, 17, 3), as_strings=True, print_per_layer_stat=True)
    print('{:<30}  {:<8}'.format('Computational complexity: ', macs))
    print('{:<30}  {:<8}'.format('Number of parameters: ', params))

Noted that FLOPs will be relevant to the input shape, e.g., (101, 17, 3) here. You need to modify it if you use different datasets.

DomineeringDragon commented 2 years ago

我是一个大四的准研究生,也是这个方向的新手,十分感谢你,这对我很有用!

VEWOXIC commented 2 years ago

If there is no further question, I will close this issue. Please feel free to reopen this if you still need help. :)