---
title: nn.modules.transformer API Reference
description: Learn about Ultralytics transformer encoder, layer, MLP block, LayerNorm2d and the deformable transformer decoder layer. Expand your understanding of these crucial AI modules.
keywords: Ultralytics, Ultralytics documentation, TransformerEncoderLayer, TransformerLayer, MLPBlock, LayerNorm2d, DeformableTransformerDecoderLayer
---

# Reference for `ultralytics/nn/modules/transformer.py`

!!! success "Improvements"

    This page is sourced from [https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/modules/transformer.py](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/modules/transformer.py). Have an improvement or example to add? Open a [Pull Request](https://docs.ultralytics.com/help/contributing) — thank you! 🙏

<br>

## ::: ultralytics.nn.modules.transformer.TransformerEncoderLayer

<br><br><hr><br>

## ::: ultralytics.nn.modules.transformer.AIFI

<br><br><hr><br>

## ::: ultralytics.nn.modules.transformer.TransformerLayer

<br><br><hr><br>

## ::: ultralytics.nn.modules.transformer.TransformerBlock

<br><br><hr><br>

## ::: ultralytics.nn.modules.transformer.MLPBlock

<br><br><hr><br>

## ::: ultralytics.nn.modules.transformer.MLP

<br><br><hr><br>

## ::: ultralytics.nn.modules.transformer.LayerNorm2d

<br><br><hr><br>

## ::: ultralytics.nn.modules.transformer.MSDeformAttn

<br><br><hr><br>

## ::: ultralytics.nn.modules.transformer.DeformableTransformerDecoderLayer

<br><br><hr><br>

## ::: ultralytics.nn.modules.transformer.DeformableTransformerDecoder

<br><br>
