dongzelian / SSF

[NeurIPS'22] This is an official implementation for "Scaling & Shifting Your Features: A New Baseline for Efficient Model Tuning".
https://arxiv.org/pdf/2210.08823.pdf
MIT License
170 stars 12 forks source link

Where was the implementation of `tuning_mode`? #23

Open 2catycm opened 2 months ago

2catycm commented 2 months ago

In train.py the argument

parser.add_argument('--tuning-mode', default=None, type=str,
                    help='Method of fine-tuning (default: None')

is later passed to create_model method

model = create_model(
        args.model,
        pretrained=args.pretrained,
        num_classes=args.num_classes,
        drop_rate=args.drop,
        drop_connect_rate=args.drop_connect,  # DEPRECATED, use drop_path
        drop_path_rate=args.drop_path,
        drop_block_rate=args.drop_block,
        global_pool=args.gp,
        bn_momentum=args.bn_momentum,
        bn_eps=args.bn_eps,
        scriptable=args.torchscript,
        checkpoint_path=args.initial_checkpoint,
        tuning_mode=args.tuning_mode)

and else where I cannot see the usage of this variable args.tuning_mode. However, create_model is from timm

from timm.models import create_model, safe_model_name, resume_checkpoint, load_checkpoint,\
    convert_splitbn_model, model_parameters

Did you implement SSF's logics in timm lib?

2catycm commented 2 months ago

Now I got some idea, SSF's logics are in model folder, and timm will pass additional args into the model init method. But I am still confused why timm would call the manually written model code instead of the timm's model code.

SydCS commented 1 month ago

I had the same question. I think that it is because the @register_model decorator in models/vision_transformer.py. Refer to https://blog.csdn.net/weixin_47994925/article/details/129745845 and https://zhuanlan.zhihu.com/p/616239771.