# Res2Net

**类别：** CNN · **代码：** [`timm/models/res2net.py`](https://github.com/huggingface/pytorch-image-models/blob/main/timm/models/res2net.py) · **架构：** 9 · **预训练权重：** 9（9 个具有 ImageNet-1k 结果）

Res2Net 将瓶颈块的通道划分为层级连接的组，从而在一个块内提供多种感受野大小。包含 Res2NeXt。

## 论文

* [Res2Net：一种新的多尺度骨干网络架构](https://arxiv.org/abs/1904.01169)

## 用法

请参阅[快速入门](../quickstart)了解如何加载预训练权重、进行图像预处理和微调，以及参阅[特征提取](../feature_extraction)了解如何将这些模型用作骨干网络。

```py
>>> import timm
>>> model = timm.create_model('res2net50_14w_8s.in1k', pretrained=True)
>>> data_config = timm.data.resolve_model_data_config(model)
```

## 模型 API 支持

| 功能 | `ResNet` |
|---|---|
| [`features_only=True` 特征图](../model_api#intermediate-features) | ✓（步长 2、4、8、16、32） |
| [`forward_intermediates()`](../model_api#intermediate-features) | ✓ |
| [`prune_intermediate_layers()`](../model_api#intermediate-features) | ✓ |
| [任意输入尺寸，无需更改](../model_api#input-size) | ✓ |
| [`set_input_size()`](../model_api#input-size) | – |
| [`dynamic_img_size=True`](../model_api#input-size) | – |
| [`set_grad_checkpointing()`](../model_api#training-hooks) | ✓ |
| [逐层学习率衰减（`group_matcher()`）](../model_api#training-hooks) | ✓ |
| [`reset_classifier()`](../model_api#classifier) | ✓ |

✓ 支持，✓ (square) 仅支持方形尺寸，✗ 不支持，– 无需支持（模型本身已接受任意输入尺寸）。通过在每个功能上运行随机初始化的模型（`ResNet` 使用 `res2next50`，尺寸为 224）进行验证，预期同一类的其他架构表现相同。详情请参阅 [Model API](../model_api) 页面。

## 架构

| 架构 | 参数（M） | GMAC | 输入大小 | 预训练权重 |
|---|---:|---:|---:|---:|
| `res2net50_14w_8s` | 25.06 | 4.21 | 224 | 1 |
| `res2net50_26w_4s` | 25.70 | 4.28 | 224 | 1 |
| `res2net50_26w_6s` | 37.05 | 6.33 | 224 | 1 |
| `res2net50_26w_8s` | 48.40 | 8.37 | 224 | 1 |
| `res2net50_48w_2s` | 25.29 | 4.18 | 224 | 1 |
| `res2net50d` | 25.72 | 4.52 | 224 | 1 |
| `res2net101_26w_4s` | 45.21 | 8.10 | 224 | 1 |
| `res2net101d` | 45.23 | 8.35 | 224 | 1 |
| `res2next50` | 24.67 | 4.20 | 224 | 1 |

GMACs 和参数量对应于每种架构的默认输入大小和分类器，数据来自[基准测试结果](https://github.com/huggingface/pytorch-image-models/tree/main/results)。

## 预训练权重

Top-1 是在所列评估规模下，来自 [`results-imagenet.csv`](https://github.com/huggingface/pytorch-image-models/blob/main/results/results-imagenet.csv) 的 ImageNet-1k 验证准确率，- 表示该权重没有 ImageNet-1k 结果（例如预训练权重或图文权重）。Classes 是预训练分类器的大小，对于没有分类器的权重则为无。

| 权重 | 输入大小 | Top-1（%） | 评估大小 | 类 | 许可证 | Hub |
|---|---:|---:|---:|---:|---|---|
| `res2net50_14w_8s.in1k` | 224 | 78.142 | 224 | 1000 | unknown | [timm](https://huggingface.co/timm/res2net50_14w_8s.in1k) |
| `res2net50_26w_4s.in1k` | 224 | 77.994 | 224 | 1000 | unknown | [timm](https://huggingface.co/timm/res2net50_26w_4s.in1k) |
| `res2net50_26w_6s.in1k` | 224 | 78.586 | 224 | 1000 | unknown | [timm](https://huggingface.co/timm/res2net50_26w_6s.in1k) |
| `res2net50_26w_8s.in1k` | 224 | 78.950 | 224 | 1000 | unknown | [timm](https://huggingface.co/timm/res2net50_26w_8s.in1k) |
| `res2net50_48w_2s.in1k` | 224 | 77.528 | 224 | 1000 | unknown | [timm](https://huggingface.co/timm/res2net50_48w_2s.in1k) |
| `res2net50d.in1k` | 224 | 80.280 | 224 | 1000 | unknown | [timm](https://huggingface.co/timm/res2net50d.in1k) |
| `res2net101_26w_4s.in1k` | 224 | 79.192 | 224 | 1000 | unknown | [timm](https://huggingface.co/timm/res2net101_26w_4s.in1k) |
| `res2net101d.in1k` | 224 | 81.236 | 224 | 1000 | unknown | [timm](https://huggingface.co/timm/res2net101d.in1k) |
| `res2next50.in1k` | 224 | 78.238 | 224 | 1000 | unknown | [timm](https://huggingface.co/timm/res2next50.in1k) |

