Giter Club home page Giter Club logo

mnist-dits's Introduction

mnist-dits

Diffusion Transformers (DiTs) trained on MNIST dataset

用transformer模型替代unet,用于实现diffusion扩散模型。

训练数据集使用了MNIST手写数字,模型传入要生成的数字,生成对应的图片。

模型结构

该项目是基于我此前开源的3个项目的认知之上来构建的,它们分别是:

DiT模型本质上是diffusion扩散模型,只是将图像部分的unet卷积网络换成了vits网络,而vits网络则基于transformer处理图像。

在diffusion复现模型中,我也已经尝试过使用cross-attention结构引导图像生成的数字,而在DiT模型中我采用adaLN-Zero方式引导图像生成,这是DiT模型与此前3个模型之间的关系。

重要的超参数如下,参数规模必须到达一定量级才能收敛:

  • embedding采用64位
  • DiT Block采用3头注意力,堆叠3层

训练

python train.py

epoch:0 iter:0,loss:0.908275842666626
epoch:5 iter:1000,loss:0.11482685804367065
epoch:10 iter:2000,loss:0.0913834497332573
epoch:15 iter:3000,loss:0.08441796898841858
epoch:20 iter:4000,loss:0.07487974315881729
epoch:25 iter:5000,loss:0.07493330538272858
epoch:30 iter:6000,loss:0.0735548809170723
epoch:35 iter:7000,loss:0.06502658873796463
epoch:40 iter:8000,loss:0.06440811604261398
epoch:45 iter:9000,loss:0.06878958642482758
epoch:50 iter:10000,loss:0.06336584687232971
...

生成

扩散生成0~9对应的图片

python inference.py

参考论文

Scalable Diffusion Models with Transformers

mnist-dits's People

Contributors

owenliang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.