ランキングに戻る

keyu-tian/SparK

Pythonarxiv.org/abs/2301.03580

[ICLR'23 Spotlight🔥] The first successful BERT/MAE-style pretraining on any convolutional network; Pytorch impl. of "Designing BERT for Convolutional Networks: Sparse and Hierarchical Masked Modeling"

bertconvnetconvolutional-neural-networksmasked-image-modelingpre-trained-modelself-supervised-learningsparse-convolutionsslcnniclriclr2023deep-learning
スター成長
スター
1.4k
フォーク
84
週間成長
Issue
15
5001k
2023年1月2024年3月2025年5月2026年7月
成果物PyPIpip install spark
README

SparK: the first successful BERT/MAE-style pretraining on any convolutional networks  Reddit Twitter

This is the official implementation of ICLR paper Designing BERT for Convolutional Networks: Sparse and Hierarchical Masked Modeling, which can pretrain any CNN (e.g., ResNet) in a BERT-style self-supervised manner. We've tried our best to make the codebase clean, short, easy to read, state-of-the-art, and only rely on minimal dependencies.

https://user-images.githubusercontent.com/39692511/226858919-dd4ccf7e-a5ba-4a33-ab21-4785b8a7833c.mp4


SOTA  OpenReview  arXiv

🔥 News

🕹️ Colab Visualization Demo

Check pretrain/viz_reconstruction.ipynb for visualizing the reconstruction of SparK pretrained models, like:

We also provide pretrain/viz_spconv.ipynb that shows the "mask pattern vanishing" issue of dense conv layers.

What's new here?

🔥 Pretrained CNN beats pretrained Swin-Transformer:

🔥 After SparK pretraining, smaller models can beat un-pretrained larger models:

🔥 All models can benefit, showing a scaling behavior:

🔥 Generative self-supervised pretraining surpasses contrastive learning:

See our paper for more analysis, discussions, and evaluations.

Todo list

catalog

Pretrained weights (self-supervised; w/o decoder; can be directly finetuned)

Note: for network definitions, we directly use timm.models.ResNet and official ConvNeXt.

reso.: the image resolution; acc@1: ImageNet-1K finetuned acc (top-1)

arch. reso. acc@1 #params flops weights (self-supervised, without SparK's decoder)
ResNet50 224 80.6 26M 4.1G resnet50_1kpretrained_timm_style.pth
ResNet101 224 82.2 45M 7.9G resnet101_1kpretrained_timm_style.pth
ResNet152 224 82.7 60M 11.6G resnet152_1kpretrained_timm_style.pth
ResNet200 224 83.1 65M 15.1G resnet200_1kpretrained_timm_style.pth
ConvNeXt-S 224 84.1 50M 8.7G convnextS_1kpretrained_official_style.pth
ConvNeXt-B 224 84.8 89M 15.4G convnextB_1kpretrained_official_style.pth
ConvNeXt-L 224 85.4 198M 34.4G convnextL_1kpretrained_official_style.pth
ConvNeXt-L 384 86.0 198M 101.0G convnextL_384_1kpretrained_official_style.pth
Pretrained weights (with SparK's UNet-style decoder; can be used to reconstruct images)
arch. reso. acc@1 #params flops weights (self-supervised, with SparK's decoder)
ResNet50 224 80.6 26M 4.1G res50_withdecoder_1kpretrained_spark_style.pth
ResNet101 224 82.2 45M 7.9G res101_withdecoder_1kpretrained_spark_style.pth
ResNet152 224 82.7 60M 11.6G res152_withdecoder_1kpretrained_spark_style.pth
ResNet200 224 83.1 65M 15.1G res200_withdecoder_1kpretrained_spark_style.pth
ConvNeXt-S 224 84.1 50M 8.7G cnxS224_withdecoder_1kpretrained_spark_style.pth
ConvNeXt-L 384 86.0 198M 101.0G cnxL384_withdecoder_1kpretrained_spark_style.pth

Installation & Running

We highly recommended you to use torch==1.10.0, torchvision==0.11.1, and timm==0.5.4 for reproduction. Check INSTALL.md to install all pip dependencies.

  • Loading pretrained model weights in 3 lines
# download our weights `resnet50_1kpretrained_timm_style.pth` first
import torch, timm
res50, state = timm.create_model('resnet50'), torch.load('resnet50_1kpretrained_timm_style.pth', 'cpu')
res50.load_state_dict(state.get('module', state), strict=False)     # just in case the model weights are actually saved in state['module']

Acknowledgement

We referred to these useful codebases:

License

This project is under the MIT license. See LICENSE for more details.

Citation

If you found this project useful, you can kindly give us a star ⭐, or cite us in your work 📖:

@Article{tian2023designing,
  author  = {Keyu Tian and Yi Jiang and Qishuai Diao and Chen Lin and Liwei Wang and Zehuan Yuan},
  title   = {Designing BERT for Convolutional Networks: Sparse and Hierarchical Masked Modeling},
  journal = {arXiv:2301.03580},
  year    = {2023},
}
関連リポジトリ
datawhalechina/leedl-tutorial

《李宏毅深度学习教程》(李宏毅老师推荐👍,苹果书🍎),PDF下载地址:https://github.com/datawhalechina/leedl-tutorial/releases

Jupyter NotebookOthermachine-learningdeep-learning
16.7k3.1k
graykode/nlp-tutorial

Natural Language Processing Tutorial for Deep Learning Researchers

Jupyter NotebookMIT Licensenlpnatural-language-processing
reddit.com/r/MachineLearning/comments/amfinl/project_nlptutoral_repository_who_is_studying/
14.9k3.9k
PaddlePaddle/PaddleNLP

Easy-to-use and powerful LLM and SLM library with awesome model zoo.

PythonPyPIApache License 2.0nlpembedding
paddlenlp.readthedocs.io
13k3k
jina-ai/clip-as-service

🏄 Scalable embedding, reasoning, ranking for images and sentences with CLIP

PythonPyPIOtherbertsentence-encoding
clip-as-service.jina.ai
12.8k2.1k
NielsRogge/Transformers-Tutorials

This repository contains demos I made with the Transformers library by HuggingFace.

Jupyter NotebookMIT Licensetransformerspytorch
11.7k1.7k
huggingface/tokenizers

💥 Fast State-of-the-Art Tokenizers optimized for Research and Production

Rustcrates.ioApache License 2.0nlpnatural-language-processing
huggingface.co/docs/tokenizers
10.9k1.2k
ymcui/Chinese-BERT-wwm

Pre-Training with Whole Word Masking for Chinese BERT(中文BERT-wwm系列模型)

PythonPyPIApache License 2.0chinese-berttensorflow
ieeexplore.ieee.org/document/9599397
10.2k1.4k
brightmart/nlp_chinese_corpus

大规模中文自然语言处理语料 Large Scale Chinese Corpus for NLP

MIT Licensechinese-datasetchinese-corpus
9.9k1.6k
fishaudio/Bert-VITS2

vits2 backbone with multilingual-bert

PythonPyPIGNU Affero General Public License v3.0bertbert-vits2
8.8k1.3k
jessevig/bertviz

BertViz: Visualize Attention in Transformer Models

PythonPyPIApache License 2.0natural-language-processingmachine-learning
8.1k886
MaartenGr/BERTopic

Leveraging BERT and c-TF-IDF to create easily interpretable topics.

PythonPyPIMIT Licenseberttransformers
maartengr.github.io/BERTopic/
7.8k909
codertimo/BERT-pytorch

Google AI 2018 BERT pytorch implementation

PythonPyPIApache License 2.0berttransformer
6.5k1.3k