pytorch_revgrad
A pytorch module (and function) to reverse gradients.
Decision gist · record as of 2026-08-14
Yes, if you need gradient reversal for adversarial training or domain adaptation and your PyTorch version is compatible. The low install friction and permissive license make it a straightforward addition. However, verify that the package works with your specific PyTorch version first, given the dormant maintenance status and last release in 2021. For new projects, consider whether a custom autograd Function might be more maintainable long-term.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Low friction install with only numpy and torch as dependencies.
- Dormant maintenance status—last release was 2021-01-09 and no commits since 2024-11-04—but the repository remains active and the package is straightforward enough that infrequent updates are not inherently a risk.
License · maintenance · safety
permissive license (permissive) — MIT license (permissive) means you can use, modify, and distribute this package freely in both open and closed projects with minimal restrictions.
last release 2021-01-09 (2043 days) · last repo commit 2024-11-04 · 158 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 224,317 downloads/mo, #9,235 on PyPI
Alternatives
Verify before relying
pip install pytorch-revgrad
import torch
from pytorch_revgrad import RevGrad
model = torch.nn.Sequential(
torch.nn.Linear(10, 5),
torch.nn.Linear(5, 2),
RevGrad()
)- Whether gradient reversal behavior matches current PyTorch conventions and autograd semantics in modern PyTorch versions.
- Whether the package has been tested against recent PyTorch releases or if compatibility issues exist.
What it is and what it does
pytorch-revgrad provides a single-purpose layer that reverses gradients during backpropagation, a technique used in adversarial training and domain adaptation. It wraps PyTorch's autograd mechanism to negate gradients flowing backward through the layer while preserving the forward pass unchanged. The layer integrates directly into torch.nn.Sequential or custom models as a drop-in module.
The package depends only on numpy and torch, making it lightweight to install. It targets a specific algorithmic need rather than a broad framework—if your model requires gradient reversal for adversarial objectives (such as domain-adversarial neural networks), this layer provides that functionality without additional overhead. The dormant maintenance status and age of the codebase mean you should verify compatibility with your PyTorch version before relying on it in production.
Use it for
- Domain adaptation: reverse gradients in a discriminator to train domain-invariant feature extractors.
- Adversarial training: implement gradient reversal for adversarial loss objectives in multi-task learning.
- Feature learning: use RevGrad to prevent a classifier from learning domain-specific features during transfer learning.
- Research prototyping: quickly add gradient reversal to experimental architectures without custom autograd code.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need gradient reversal for adversarial training or domain adaptation and your PyTorch version is compatible.
The low install friction and permissive license make it a straightforward addition. However, verify that the package works with your specific PyTorch version first, given the dormant maintenance status and last release in 2021. For new projects, consider whether a custom autograd Function might be more maintainable long-term.
Install
pytorch-revgrad on PyPI
Before you install
Low friction install with only numpy and torch as dependencies. Dormant maintenance status—last release was 2021-01-09 and no commits since 2024-11-04—but the repository remains active and the package is straightforward enough that infrequent updates are not inherently a risk.
License in practice
MIT license (permissive) means you can use, modify, and distribute this package freely in both open and closed projects with minimal restrictions.
Quickstart
pip install pytorch-revgrad
import torch
from pytorch_revgrad import RevGrad
model = torch.nn.Sequential(
torch.nn.Linear(10, 5),
torch.nn.Linear(5, 2),
RevGrad()
)
Verify before relying
- Whether gradient reversal behavior matches current PyTorch conventions and autograd semantics in modern PyTorch versions.
- Whether the package has been tested against recent PyTorch releases or if compatibility issues exist.
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.5 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 2 packagesnumpytorch |
| Maintenance | Dormant 2,043 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 224,317 / month, #9,235 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | License :: OSI Approved :: MIT License |
Evidence: pytorch_revgrad-0.2.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “gradient reversal pytorch”
- pytorch_revgradImplements a gradient reversal layer for PyTorch neural networks,…
- pytorch_optimizerProvides a collection of modern optimizers, learning rate schedulers,…
- schedulefreeProvides schedule-free optimizers for PyTorch that eliminate the need…
Give your agent the search over MCP, or paste the wish link into any chat.
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to call 100+ LLM providers (OpenAI, Anthropic, Gemini, Bedrock, Azure, and others) using OpenAI-compatible API format, available as both a Python SDK and a self-hosted AI Gateway proxy server.
Install it if you need to work with multiple LLM providers or want to centralize LLM routing in your organization.
Client library and CLI tool for downloading, uploading, and managing models, datasets, and repositories on the Hugging Face Hub platform.
Install it if you work with Hugging Face Hub models or datasets.
LangChain provides a framework for building agents and LLM-powered applications by composing language models, tools, and memory through a unified API that abstracts over multiple model providers.
hf-xet provides chunk-based deduplication and efficient file transfer for the Hugging Face Hub, enabling faster uploads and downloads of large files with local disk caching.
Tokenizers converts raw text into token sequences for NLP models, with support for training custom vocabularies and using pre-built tokenizers (BPE, WordPiece) optimized for speed via Rust.
Transformers provides a unified framework for loading, fine-tuning, and running state-of-the-art pretrained models across text, vision, audio, video, and multimodal tasks using PyTorch, JAX, or TensorFlow.
Install it if you need to run or train any transformer-based model for NLP, vision, audio, or multimodal tasks.
See also pytorch_optimizer · torch · torchsde · autograd · torchdiffeq · pytorchcv · torchsr · torch-geometric · pytorch-wavelets · NeuralFoil