Git Product home page Git Product logo

vision_transformer's Introduction

Vision Transformer

ViT with self attention and CVit with cross attention

trainer.py

execute the basic training and testing process

use the early_stopping and data augmentation with torch.transform()

contains three models:

ResNet-18 as pretrained model

ViT as Vision Transformer

CrossViT

my_models.py

implementing the ViT and CViT

ViT uses the self attention mechanism and the multi-head attention

Attention(Q,K,V) = softmax(Q K^T/sqrt(d_k)) V
Q is the query matrix, K is the key matrix, V is the value matrix
d_k is the dimension of the key matrix

CrossViT with cross attention considered the class token and patch token from both small and big tokens It can fuse the global and local information better than vanilla ViT.

The general structure of CrossViT is as follows:

ImageEmbedder() x2 for L and S

Multi-scale Encoder():
{
  Transformer for L
  Transformer for S
  Cross Transformer for L and S
  {
      ProjIn
      Attention
      ProjOut
  }
}
  
Classifier() as MLP head

vision_transformer's People

Contributors

trevorkang avatar

Watchers

 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.