timm documentation

ResNetV2 (BiT)

Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

ResNetV2 (BiT)

Category: CNN · Code: timm/models/resnetv2.py · Architectures: 20 · Pretrained weights: 24 (18 with ImageNet-1k results)

Pre-activation ResNet (v2) with Group Normalization and Weight Standardization as used by Big Transfer (BiT), with the original BiT weights. Also supports the non pre-activation variant used as the hybrid Vision Transformer backbone.

Papers

Usage

See the Quickstart for loading pretrained weights, image preprocessing and fine-tuning, and Feature Extraction for using the models as backbones.

>>> import timm
>>> model = timm.create_model('resnetv2_50.a1h_in1k', pretrained=True)
>>> data_config = timm.data.resolve_model_data_config(model)

Model API support

FeatureResNetV2
features_only=True feature maps✓ (strides 2, 4, 8, 16, 32)
forward_intermediates()✓
prune_intermediate_layers()✓
Any input size, no changes needed✓
set_input_size()–
dynamic_img_size=True–
set_grad_checkpointing()✓
Layer-wise LR decay (group_matcher())✓
reset_classifier()✓

✓ supported, ✓ (square) works for square sizes only, ✗ not supported, – not needed (the model already accepts any input size). Checked by running each feature on a randomly initialized model (ResNetV2 with resnetv2_18 at 224), other architectures of the same class are expected to behave the same. See the Model API page for details.

Architectures

ArchitectureParams (M)GMACsInput sizePretrained weights
resnetv2_1811.691.822241
resnetv2_18d11.712.062241
resnetv2_3421.803.672241
resnetv2_34d21.823.912242
resnetv2_5025.554.112241
resnetv2_50d25.574.352240
resnetv2_50d_evos25.594.332241
resnetv2_50d_frn25.594.332240
resnetv2_50d_gn25.574.382241
resnetv2_50t25.574.322240
resnetv2_50x1_bit25.554.232243
resnetv2_50x3_bit217.32145.704482
resnetv2_10144.547.832241
resnetv2_101d44.568.072240
resnetv2_101x1_bit44.5431.654482
resnetv2_101x3_bit387.93280.334482
resnetv2_15260.1911.552240
resnetv2_152d60.2011.802240
resnetv2_152x2_bit236.3446.952244
resnetv2_152x4_bit936.53844.844802

GMACs and parameter counts are for the default input size and classifier of each architecture, from the benchmark results.

Pretrained weights

Top-1 is ImageNet-1k validation accuracy from results-imagenet.csv at the listed eval size, - if the weight has no ImageNet-1k result (e.g. pretraining or image-text weights). Classes is the size of the pretrained classifier, none for weights without one.

Weights are grouped by source: the paper or origin given in the pretrained config, else a Hub organization other than timm, else the first part of the pretrained tag (architecture.tag). Sources with a single weight are listed under other.

goog tags

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
resnetv2_50x1_bit.goog_distilled_in1k22482.8202241000apache-2.0timm
resnetv2_50x1_bit.goog_in21k224--21843apache-2.0timm
resnetv2_50x1_bit.goog_in21k_ft_in1k44880.3864481000apache-2.0timm
resnetv2_50x3_bit.goog_in21k224--21843apache-2.0timm
resnetv2_50x3_bit.goog_in21k_ft_in1k44883.9824481000apache-2.0timm
resnetv2_101x1_bit.goog_in21k224--21843apache-2.0timm
resnetv2_101x1_bit.goog_in21k_ft_in1k44882.3324481000apache-2.0timm
resnetv2_101x3_bit.goog_in21k224--21843apache-2.0timm
resnetv2_101x3_bit.goog_in21k_ft_in1k44884.4304481000apache-2.0timm
resnetv2_152x2_bit.goog_in21k224--21843apache-2.0timm
resnetv2_152x2_bit.goog_in21k_ft_in1k44884.4684481000apache-2.0timm
resnetv2_152x2_bit.goog_teacher_in21k_ft_in1k22482.9182241000apache-2.0timm
resnetv2_152x2_bit.goog_teacher_in21k_ft_in1k_38438483.8583841000apache-2.0timm
resnetv2_152x4_bit.goog_in21k224--21843apache-2.0timm
resnetv2_152x4_bit.goog_in21k_ft_in1k48084.9364801000apache-2.0timm

ra4 tags

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
resnetv2_18.ra4_e3600_r224_in1k224 (test 288)75.3642881000apache-2.0timm
resnetv2_18d.ra4_e3600_r224_in1k224 (test 288)76.0582881000apache-2.0timm
resnetv2_34.ra4_e3600_r224_in1k224 (test 288)79.0702881000apache-2.0timm
resnetv2_34d.ra4_e3600_r224_in1k224 (test 288)79.6142881000apache-2.0timm
resnetv2_34d.ra4_e3600_r384_in1k384 (test 448)80.4304481000apache-2.0timm

a1h tags

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
resnetv2_50.a1h_in1k224 (test 288)81.4062881000apache-2.0timm
resnetv2_101.a1h_in1k224 (test 288)83.0022881000apache-2.0timm

ah tags

WeightInput sizeTop-1 (%)Eval sizeClassesLicenseHub
resnetv2_50d_evos.ah_in1k224 (test 288)82.0242881000apache-2.0timm
resnetv2_50d_gn.ah_in1k224 (test 288)81.9602881000apache-2.0timm
Update on GitHub