# XCiT

**Kategori:** ViT · **Kod:** [`timm/models/xcit.py`](https://github.com/huggingface/pytorch-image-models/blob/main/timm/models/xcit.py) · **Mimariler:** 28 · **Önceden eğitilmiş ağırlıklar:** 42 (42'si ImageNet-1k sonuçlarıyla)

Cross-Covariance Image Transformers (XCiT), token öz-dikkatini (self-attention) yerini, token sayısına lineer olan ve özellik kanalları arasında çapraz kovaryans dikkati (cross-covariance attention) ile değiştirir ve yerel yama etkileşim katmanları ekler.

## Makaleler

* [XCiT: Çapraz Kovaryans Görüntü Dönüşümcüleri](https://arxiv.org/abs/2106.09681)

## Kullanım

Önceden eğitilmiş ağırlıkları yükleme, görüntü ön işleme ve ince ayar için [Hızlı Başlangıç](../quickstart) bölümüne, modelleri omurga olarak kullanmak için ise [Özellik Çıkarımı](../feature_extraction) bölümüne bakın.

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

## Model API desteği

| Özellik | `Xcit` |
|---|---|
| [`features_only=True` özellik haritaları](../model_api#intermediate-features) | ✓ (adım 8, 8, 8) |
| [`forward_intermediates()`](../model_api#intermediate-features) | ✓ |
| [`prune_intermediate_layers()`](../model_api#intermediate-features) | ✓ |
| [Herhangi bir giriş boyutu, değişiklik gerekmez](../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) | ✓ |
| [Katman bazlı LR azaltma (`group_matcher()`)](../model_api#training-hooks) | ✓ |
| [`reset_classifier()`](../model_api#classifier) | ✓ |

✓ destekleniyor, ✓ (kare) yalnızca kare boyutlarda çalışır, ✗ desteklenmiyor, – gerekli değil (model zaten herhangi bir giriş boyutunu kabul eder). Her özellik, rastgele başlatılmış bir model üzerinde çalıştırılarak kontrol edilir (`Xcit`, 224 boyutunda `xcit_nano_12_p8_224`), aynı sınıftaki diğer mimarilerin de aynı şekilde davranması beklenir. Ayrıntılar için [Model API](../model_api) sayfasına bakın.

## Mimariler

| Mimari | Parametreler (M) | GMAC'lar | Girdi boyutu | Önceden eğitilmiş ağırlıklar |
|---|---:|---:|---:|---:|
| `xcit_large_24_p8_224` | 188.93 | 141.23 | 224 | 2 |
| `xcit_large_24_p8_384` | 188.93 | 415.00 | 384 | 1 |
| `xcit_large_24_p16_224` | 189.10 | 35.86 | 224 | 2 |
| `xcit_large_24_p16_384` | 189.10 | 105.35 | 384 | 1 |
| `xcit_medium_24_p8_224` | 84.32 | 63.53 | 224 | 2 |
| `xcit_medium_24_p8_384` | 84.32 | 186.67 | 384 | 1 |
| `xcit_medium_24_p16_224` | 84.40 | 16.13 | 224 | 2 |
| `xcit_medium_24_p16_384` | 84.40 | 47.39 | 384 | 1 |
| `xcit_nano_12_p8_224` | 3.05 | 2.16 | 224 | 2 |
| `xcit_nano_12_p8_384` | 3.05 | 6.34 | 384 | 1 |
| `xcit_nano_12_p16_224` | 3.05 | 0.56 | 224 | 2 |
| `xcit_nano_12_p16_384` | 3.05 | 1.64 | 384 | 1 |
| `xcit_small_12_p8_224` | 26.21 | 18.69 | 224 | 2 |
| `xcit_small_12_p8_384` | 26.21 | 54.92 | 384 | 1 |
| `xcit_small_12_p16_224` | 26.25 | 4.82 | 224 | 2 |
| `xcit_small_12_p16_384` | 26.25 | 14.14 | 384 | 1 |
| `xcit_small_24_p8_224` | 47.63 | 35.81 | 224 | 2 |
| `xcit_small_24_p8_384` | 47.63 | 105.24 | 384 | 1 |
| `xcit_small_24_p16_224` | 47.67 | 9.10 | 224 | 2 |
| `xcit_small_24_p16_384` | 47.67 | 26.72 | 384 | 1 |
| `xcit_tiny_12_p8_224` | 6.71 | 4.81 | 224 | 2 |
| `xcit_tiny_12_p8_384` | 6.71 | 14.13 | 384 | 1 |
| `xcit_tiny_12_p16_224` | 6.72 | 1.24 | 224 | 2 |
| `xcit_tiny_12_p16_384` | 6.72 | 3.64 | 384 | 1 |
| `xcit_tiny_24_p8_224` | 12.11 | 9.21 | 224 | 2 |
| `xcit_tiny_24_p8_384` | 12.11 | 27.05 | 384 | 1 |
| `xcit_tiny_24_p16_224` | 12.12 | 2.34 | 224 | 2 |
| `xcit_tiny_24_p16_384` | 12.12 | 6.87 | 384 | 1 |

GMAC'lar ve parametre sayıları, her mimarinin varsayılan giriş boyutu ve sınıflandırıcısı içindir ve [benchmark sonuçlarından](https://github.com/huggingface/pytorch-image-models/tree/main/results) alınmıştır.

## Önceden eğitilmiş ağırlıklar

Top-1, belirtilen değerlendirme boyutunda [`results-imagenet.csv`](https://github.com/huggingface/pytorch-image-models/blob/main/results/results-imagenet.csv) dosyasındaki ImageNet-1k doğrulama doğruluğudur, - ağırlığın ImageNet-1k sonucu yoksa (ör. ön eğitim veya görsel-metin ağırlıkları). Classes, ön eğitilmiş sınıflandırıcının boyutudur; sınıflandırıcısı olmayan ağırlıklar için yoktur.

| Ağırlık | Girdi boyutu | En iyi 1 (%) | Değerlendirme boyutu | Sınıflar | Lisans | Hub |
|---|---:|---:|---:|---:|---|---|
| `xcit_large_24_p8_224.fb_dist_in1k` | 224 | 85.396 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_large_24_p8_224.fb_dist_in1k) |
| `xcit_large_24_p8_224.fb_in1k` | 224 | 84.380 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_large_24_p8_224.fb_in1k) |
| `xcit_large_24_p8_384.fb_dist_in1k` | 384 | 86.024 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_large_24_p8_384.fb_dist_in1k) |
| `xcit_large_24_p16_224.fb_dist_in1k` | 224 | 84.936 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_large_24_p16_224.fb_dist_in1k) |
| `xcit_large_24_p16_224.fb_in1k` | 224 | 82.886 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_large_24_p16_224.fb_in1k) |
| `xcit_large_24_p16_384.fb_dist_in1k` | 384 | 85.778 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_large_24_p16_384.fb_dist_in1k) |
| `xcit_medium_24_p8_224.fb_dist_in1k` | 224 | 85.078 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_medium_24_p8_224.fb_dist_in1k) |
| `xcit_medium_24_p8_224.fb_in1k` | 224 | 83.744 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_medium_24_p8_224.fb_in1k) |
| `xcit_medium_24_p8_384.fb_dist_in1k` | 384 | 85.842 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_medium_24_p8_384.fb_dist_in1k) |
| `xcit_medium_24_p16_224.fb_dist_in1k` | 224 | 84.292 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_medium_24_p16_224.fb_dist_in1k) |
| `xcit_medium_24_p16_224.fb_in1k` | 224 | 82.630 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_medium_24_p16_224.fb_in1k) |
| `xcit_medium_24_p16_384.fb_dist_in1k` | 384 | 85.434 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_medium_24_p16_384.fb_dist_in1k) |
| `xcit_nano_12_p8_224.fb_dist_in1k` | 224 | 76.330 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_nano_12_p8_224.fb_dist_in1k) |
| `xcit_nano_12_p8_224.fb_in1k` | 224 | 73.900 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_nano_12_p8_224.fb_in1k) |
| `xcit_nano_12_p8_384.fb_dist_in1k` | 384 | 77.810 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_nano_12_p8_384.fb_dist_in1k) |
| `xcit_nano_12_p16_224.fb_dist_in1k` | 224 | 72.318 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_nano_12_p16_224.fb_dist_in1k) |
| `xcit_nano_12_p16_224.fb_in1k` | 224 | 69.982 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_nano_12_p16_224.fb_in1k) |
| `xcit_nano_12_p16_384.fb_dist_in1k` | 384 | 75.460 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_nano_12_p16_384.fb_dist_in1k) |
| `xcit_small_12_p8_224.fb_dist_in1k` | 224 | 84.252 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_12_p8_224.fb_dist_in1k) |
| `xcit_small_12_p8_224.fb_in1k` | 224 | 83.354 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_12_p8_224.fb_in1k) |
| `xcit_small_12_p8_384.fb_dist_in1k` | 384 | 85.068 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_12_p8_384.fb_dist_in1k) |
| `xcit_small_12_p16_224.fb_dist_in1k` | 224 | 83.354 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_12_p16_224.fb_dist_in1k) |
| `xcit_small_12_p16_224.fb_in1k` | 224 | 81.982 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_12_p16_224.fb_in1k) |
| `xcit_small_12_p16_384.fb_dist_in1k` | 384 | 84.734 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_12_p16_384.fb_dist_in1k) |
| `xcit_small_24_p8_224.fb_dist_in1k` | 224 | 84.878 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_24_p8_224.fb_dist_in1k) |
| `xcit_small_24_p8_224.fb_in1k` | 224 | 83.854 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_24_p8_224.fb_in1k) |
| `xcit_small_24_p8_384.fb_dist_in1k` | 384 | 85.580 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_24_p8_384.fb_dist_in1k) |
| `xcit_small_24_p16_224.fb_dist_in1k` | 224 | 83.880 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_24_p16_224.fb_dist_in1k) |
| `xcit_small_24_p16_224.fb_in1k` | 224 | 82.588 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_24_p16_224.fb_in1k) |
| `xcit_small_24_p16_384.fb_dist_in1k` | 384 | 85.102 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_small_24_p16_384.fb_dist_in1k) |
| `xcit_tiny_12_p8_224.fb_dist_in1k` | 224 | 81.214 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_12_p8_224.fb_dist_in1k) |
| `xcit_tiny_12_p8_224.fb_in1k` | 224 | 79.710 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_12_p8_224.fb_in1k) |
| `xcit_tiny_12_p8_384.fb_dist_in1k` | 384 | 82.394 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_12_p8_384.fb_dist_in1k) |
| `xcit_tiny_12_p16_224.fb_dist_in1k` | 224 | 78.572 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_12_p16_224.fb_dist_in1k) |
| `xcit_tiny_12_p16_224.fb_in1k` | 224 | 77.122 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_12_p16_224.fb_in1k) |
| `xcit_tiny_12_p16_384.fb_dist_in1k` | 384 | 80.954 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_12_p16_384.fb_dist_in1k) |
| `xcit_tiny_24_p8_224.fb_dist_in1k` | 224 | 82.578 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_24_p8_224.fb_dist_in1k) |
| `xcit_tiny_24_p8_224.fb_in1k` | 224 | 81.888 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_24_p8_224.fb_in1k) |
| `xcit_tiny_24_p8_384.fb_dist_in1k` | 384 | 83.784 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_24_p8_384.fb_dist_in1k) |
| `xcit_tiny_24_p16_224.fb_dist_in1k` | 224 | 80.462 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_24_p16_224.fb_dist_in1k) |
| `xcit_tiny_24_p16_224.fb_in1k` | 224 | 79.474 | 224 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_24_p16_224.fb_in1k) |
| `xcit_tiny_24_p16_384.fb_dist_in1k` | 384 | 82.580 | 384 | 1000 | apache-2.0 | [timm](https://huggingface.co/timm/xcit_tiny_24_p16_384.fb_dist_in1k) |

