Top AI Repos — open-source AI, indexed and scored
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Top AI Repos tracks AI repositories on GitHub and answers two different questions about each one: is it moving right now, and would you bet a product on it.
Domain adaptation made easy. Fully featured, modular, and customizable.
| Date | Stars |
|---|---|
| 2026-07-24 | 397 |
| 2026-07-25 | 397 |
| 2026-07-28 | 397 |
| 2026-07-30 | 397 |
| 2026-08-06 | 397 |
Today
— stars today
This week
— stars this week
This month
— stars this month
Momentum
0.0
growth rate 0.00%/day
<h1>
<a href="https://github.com/KevinMusgrave/pytorch-adapt">
<img alt="PyTorch Adapt" src="https://github.com/KevinMusgrave/pytorch-adapt/blob/main/docs/imgs/Logo.png">
</a>
</h1>
<p align="center">
<a href="https://badge.fury.io/py/pytorch-adapt">
<img alt="PyPi version" src="https://badge.fury.io/py/pytorch-adapt.svg">
</a>
</p>
## Why use PyTorch Adapt?
PyTorch Adapt provides tools for **domain adaptation**, a type of machine learning algorithm that repurposes existing models to work in new domains. This library is:
### 1. **Fully featured**
Build a complete train/val domain adaptation pipeline in a few lines of code.
### 2. **Modular**
Use just the parts that suit your needs, whether it's the algorithms, loss functions, or validation methods.
### 3. **Highly customizable**
Customize and combine complex algorithms with ease.
### 4. **Compatible with frameworks**
Add additional functionality to your code by using one of the framework wrappers. Converting an algorithm into a PyTorch Lightning module is as simple as wrapping it with ```Lightning```.
## Documentation
- [**Documentation**](https://kevinmusgrave.github.io/pytorch-adapt/)
- [**Installation instructions**](https://github.com/KevinMusgrave/pytorch-adapt#installation)
- [**List of papers implemented**](https://kevinmusgrave.github.io/pytorch-adapt/algorithms/uda)
## Examples
See the **[examples folder](https://github.com/KevinMusgrave/pytorch-adapt/blob/main/examples/README.md)** for notebooks you can download or run on Google Colab.
## How to...
### Use in vanilla PyTorch
```python
from pytorch_adapt.hooks import DANNHook
from pytorch_adapt.utils.common_functions import batch_to_device
# Assuming that models, optimizers, and dataloader are already created.
hook = DANNHook(optimizers)
for data in tqdm(dataloader):
data = batch_to_device(data, device)
# Optimization is done inside the hook.
# The returned loss is for logging.
_, loss = hook({**models, **data})
```
### Build complex algorithms
Let's customize ```DANNHook``` with:
- minimum class confusion
- virtual adversarial training
```python
from pytorch_adapt.hooks import MCCHook, VATHook
# G and C are the Generator and Classifier models
G, C = models["G"], models["C"]
misc = {"combined_model": torch.nn.Sequential(G, C)}
hook = DANNHook(optimizers, post_g=[MCCHook(), VATHook()])
for data in tqdm(dataloader):
data = batch_to_device(data, device)
_, loss = hook({**models, **data, **misc})
```
### Wrap with your favorite PyTorch framework
First, set up the adapter and dataloaders:
```python
from pytorch_adapt.adapters import DANN
from pytorch_adapt.containers import Models
from pytorch_adapt.datasets import DataloaderCreator
models_cont = Models(models)
adapter = DANN(models=models_cont)
dc = DataloaderCreator(num_workers=2)
dataloaders = dc(**datasets)
```
Then use a framework wrapper:
#### PyTorch Lightning
```python
import pytorch_lightning as pl
from pytorch_adapt.frameworks.lightning import Lightning
L_adapter = Lightning(adapter)
trainer = pl.Trainer(gpus=1, max_epochs=1)
trainer.fit(L_adapter, dataloaders["train"])
```
#### PyTorch Ignite
```python
trainer = Ignite(adapter)
trainer.run(datasets, dataloader_creator=dc)
```
### Check your model's performance
You can do this in vanilla PyTorch:
```python
from pytorch_adapt.validators import SNDValidator
# Assuming predictions have been collected
target_train = {"preds": preds}
validator = SNDValidator()
score = validator(target_train=target_train)
```
You can also do this during training with a framework wrapper:
#### PyTorch Lightning
```python
from pytorch_adapt.frameworks.utils import filter_datasets
validator = SNDValidator()
dataloaders = dc(**filter_datasets(datasets, validator))
train_loader = dataloaders.pop("train")
L_adapter = Lightning(adapter, validator=validator)
trainer = pl.Trainer(gpus=1, max_epochs=1)
trainer.fit(L_adapter, train_loader, list(dataloaders.values()))
```
#### Pytorch IgniExcerpt of 6,485 characters
Read on GitHubWould you bet a product on this? Bounded 0–100 and slow moving.
matched fp:1702fa8c92c29a13, topic:deep-learning, topic:pytorch
matched fp:1702fa8c92c29a13, topic:computer-vision