# BYOANet (BoTNet, HaloNet, LambdaNet)

**Category:** Hybrid · **Code:**
[`timm/models/byoanet.py`](https://github.com/huggingface/pytorch-image-models/blob/main/timm/models/byoanet.py) ·
**Architectures:** 15 · **Pretrained weights:** 13 (13 with ImageNet-1k results)

Networks built with the `ByobNet` block / stage config system that place self-attention (or similar) layers in ResNet
style stages: Bottleneck Transformers (BoTNet), HaloNets and Lambda ResNets. The module docstring marks these
definitions as experimental.

## Papers

* [Bottleneck Transformers for Visual Recognition](https://arxiv.org/abs/2101.11605)
* [LambdaNetworks: Modeling Long-Range Interactions Without Attention](https://arxiv.org/abs/2102.08602)
* [Scaling Local Self-Attention for Parameter Efficient Visual Backbones](https://arxiv.org/abs/2103.12731)

## Usage

See the [Quickstart](../quickstart) for loading pretrained weights, image preprocessing and fine-tuning, and [Feature
Extraction](../feature_extraction) for using the models as backbones.

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

## Model API support

| Feature | `ByobNet` |
|---|---|
| [`features_only=True` feature maps](../model_api#intermediate-features) | ✓ (strides 2, 4, 8, 16, 32) |
| [`forward_intermediates()`](../model_api#intermediate-features) | ✓ |
| [`prune_intermediate_layers()`](../model_api#intermediate-features) | ✓ |
| [Any input size, no changes needed](../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) | ✓ |
| [Layer-wise LR decay (`group_matcher()`)](../model_api#training-hooks) | ✓ |
| [`reset_classifier()`](../model_api#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 (`ByobNet` with `halonet_h1` at 256), other
architectures of the same class are expected to behave the same. See the [Model API](../model_api) page for details.

## Architectures

| Architecture | Params (M) | GMACs | Input size | Pretrained weights |
|---|---:|---:|---:|---:|
| `botnet26t_256` | 12.49 | 3.32 | 256 | 1 |
| `botnet50ts_256` | 22.74 | 5.54 | 256 | 0 |
| `eca_botnext26ts_256` | 10.59 | 2.46 | 256 | 1 |
| `eca_halonext26ts` | 10.76 | 2.44 | 256 | 1 |
| `halo2botnet50ts_256` | 22.64 | 5.02 | 256 | 1 |
| `halonet26t` | 12.48 | 3.19 | 256 | 1 |
| `halonet50ts` | 22.73 | 5.30 | 256 | 1 |
| `halonet_h1` | 8.10 | 3.00 | 256 | 0 |
| `haloregnetz_b` | 11.68 | 1.97 | 224 | 1 |
| `lambda_resnet26rpt_256` | 10.99 | 3.16 | 256 | 1 |
| `lambda_resnet26t` | 10.96 | 3.02 | 256 | 1 |
| `lambda_resnet50ts` | 21.54 | 5.07 | 256 | 1 |
| `lamhalobotnet50ts_256` | 22.57 | 5.02 | 256 | 1 |
| `sebotnet33ts_256` | 13.70 | 3.89 | 256 | 1 |
| `sehalonet33ts` | 13.69 | 3.55 | 256 | 1 |

GMACs and parameter counts are for the default input size and classifier of each architecture, from the [benchmark
results](https://github.com/huggingface/pytorch-image-models/tree/main/results).

## Pretrained weights

Top-1 is ImageNet-1k validation accuracy from
[`results-imagenet.csv`](https://github.com/huggingface/pytorch-image-models/blob/main/results/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.

### `a1h` tags

| Weight | Input size | Top-1 (%) | Eval size | Classes | License | Hub |
|---|---:|---:|---:|---:|---|---|
| `halo2botnet50ts_256.a1h_in1k` | 256 | 82.084 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/halo2botnet50ts_256.a1h_in1k) |
| `halonet26t.a1h_in1k` | 256 | 79.134 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/halonet26t.a1h_in1k) |
| `halonet50ts.a1h_in1k` | 256 | 81.640 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/halonet50ts.a1h_in1k) |
| `lambda_resnet50ts.a1h_in1k` | 256 | 81.184 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/lambda_resnet50ts.a1h_in1k) |
| `lamhalobotnet50ts_256.a1h_in1k` | 256 | 81.552 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/lamhalobotnet50ts_256.a1h_in1k) |
| `sebotnet33ts_256.a1h_in1k` | 256 | 81.156 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/sebotnet33ts_256.a1h_in1k) |

### `c1` tags

| Weight | Input size | Top-1 (%) | Eval size | Classes | License | Hub |
|---|---:|---:|---:|---:|---|---|
| `botnet26t_256.c1_in1k` | 256 | 79.256 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/botnet26t_256.c1_in1k) |
| `eca_botnext26ts_256.c1_in1k` | 256 | 79.262 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/eca_botnext26ts_256.c1_in1k) |
| `eca_halonext26ts.c1_in1k` | 256 | 79.518 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/eca_halonext26ts.c1_in1k) |
| `lambda_resnet26rpt_256.c1_in1k` | 256 | 78.960 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/lambda_resnet26rpt_256.c1_in1k) |
| `lambda_resnet26t.c1_in1k` | 256 | 79.126 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/lambda_resnet26t.c1_in1k) |

### Other

| Weight | Input size | Top-1 (%) | Eval size | Classes | License | Hub |
|---|---:|---:|---:|---:|---|---|
| `haloregnetz_b.ra3_in1k` | 224 | 81.058 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/haloregnetz_b.ra3_in1k) |
| `sehalonet33ts.ra2_in1k` | 256 | 80.976 | 256 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/sehalonet33ts.ra2_in1k) |

