---
title: "How to train your model dynamically using adversarial data"
description: "Dynamic adversarial data collection (DADC) has humans craft inputs that fool a trained model, then retrains the model on those examples over repeated rounds, countering the saturation and blind spots of static benchmarks."
url: "https://swe.quest/articles/how-to-train-your-model-dynamically-using-adversarial-data-b47b08b7da53daa6"
canonical: "https://huggingface.co/blog/mnist-adversarial"
source: "Hugging Face"
published: "2022-07-16"
difficulty: "medium"
kind: "How-to"
reading_minutes: 5
tags: ["model-training","computer-vision","evals","machine-learning"]
---

# How to train your model dynamically using adversarial data

A post on [Hugging Face](https://swe.quest/sources/hugging-face.md), published 2022-07-16, 5 min read, How-to. Original: [https://huggingface.co/blog/mnist-adversarial](https://huggingface.co/blog/mnist-adversarial)

## Summary

Dynamic adversarial data collection (DADC) has humans craft inputs that fool a trained model, then retrains the model on those examples over repeated rounds, countering the saturation and blind spots of static benchmarks. A walkthrough applies it to MNIST: a small PyTorch CNN (89% test accuracy after 20 epochs) is deployed in a Hugging Face Space where users draw digits, and a custom flag function saves misclassified samples and retrains once a threshold is reached. Cited work on natural language inference suggests standard data collection wins in the short term while DADC yields higher accuracy over many rounds.

Written by swe.quest, not by the author.

**Difficulty:** Medium: assumes a working developer; shows how it is built or done

## Topics

- [Model training](https://swe.quest/tags/model-training.md) (AI & ML)
- [Computer vision](https://swe.quest/tags/computer-vision.md) (AI & ML)
- [Evaluation](https://swe.quest/tags/evals.md) (AI & ML)
- [Machine learning](https://swe.quest/tags/machine-learning.md) (AI & ML)

## Prerequisites

- PyTorch basics
- convolutional neural networks ([easy posts on Machine learning](https://swe.quest/tags/machine-learning.md?difficulty=easy))

## Keywords

Dynamic Adversarial Data Collection, MNIST, PyTorch, Hugging Face Spaces, Gradio

## Related posts

- [Tuning Image Classifiers using Human-In-The-Loop](https://swe.quest/articles/tuning-image-classifiers-using-human-in-the-loop-f1e427f4f784a749.md): Zalando Engineering · 2021-10-12 · Hard · 18 min read · Computer vision, Machine learning, Evaluation, Algorithms, E-commerce
  AutoThreshold is an Expectation-Maximization procedure that re-tunes an image classifier's class-confidence threshold when product photos drift out of distribution and no labelled validation set exists.
- [PRX Part 3 — Training a Text-to-Image Model in 24h!](https://swe.quest/articles/prx-part-3-training-a-text-to-image-model-in-24h-e27e27a7f3c7dc41.md): Hugging Face · 2026-03-03 · Hard · 9 min read · Model training, Computer vision, Machine learning
  A 24-hour, ~$1500 speedrun on 32 H200s combines the most effective diffusion training tricks into a single text-to-image recipe.
- [CinePile 2.0 - making stronger datasets with adversarial refinement](https://swe.quest/articles/cinepile-2-0-making-stronger-datasets-with-adversarial-refinement-40e038ccf01249a9.md): Hugging Face · 2024-10-23 · Hard · 8 min read · Evaluation, Computer vision, LLMs, Model training
  CinePile 2.0 improves a long-video QA benchmark with adversarial refinement.
- [Training Design for Text-to-Image Models: Lessons from Ablations](https://swe.quest/articles/training-design-for-text-to-image-models-lessons-from-ablations-0bc11bc8d1a3210c.md): Hugging Face · 2026-02-03 · Hard · 31 min read · Model training, Computer vision, Machine learning, Evaluation
  Photoroom's ablations on its PRX-1.2B text-to-image model compare recent training-efficiency techniques against a plain Flow Matching baseline: 100k steps at 256×256 on 1M MidJourney images, scored with FID, CMMD, DINO-MMD and throughput.
- [Preference Optimization for Vision Language Models](https://swe.quest/articles/preference-optimization-for-vision-language-models-a84799e96613bf21.md): Hugging Face · 2024-07-10 · Hard · 11 min read · Model training, Computer vision, LLMs, Python
  TRL now supports direct preference optimization (DPO) for vision language models, trained on chosen/rejected answer pairs rather than fixed labels.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
