Fix Docs YAML guide missing docstrings (#22264)

Co-authored-by: UltralyticsAssistant <web@ultralytics.com>
This commit is contained in:
Glenn Jocher 2025-09-30 15:28:52 +01:00 committed by GitHub
parent 4357d6923a
commit e00bc49580
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -235,11 +235,15 @@ Modifying the source code is the most versatile way to integrate your custom mod
```python
class CustomBlock(nn.Module):
"""Custom block with Conv-BatchNorm-ReLU sequence."""
def __init__(self, c1, c2):
"""Initialize CustomBlock with input and output channels."""
super().__init__()
self.layers = nn.Sequential(nn.Conv2d(c1, c2, 3, 1, 1), nn.BatchNorm2d(c2), nn.ReLU())
def forward(self, x):
"""Forward pass through the block."""
return self.layers(x)
```
@ -258,7 +262,8 @@ Modifying the source code is the most versatile way to integrate your custom mod
5. **Handle special arguments** (if needed) inside [`parse_model()`](https://github.com/ultralytics/ultralytics/blob/main/ultralytics/nn/tasks.py) in `ultralytics/nn/tasks.py`:
```python
elif m is CustomBlock:
# Add this condition in the parse_model() function
if m is CustomBlock:
c1, c2 = ch[f], args[0] # input channels, output channels
args = [c1, c2, *args[1:]]
```