GithubHelp home page GithubHelp logo

niuxiaopaier / stand-alone-axial-attention Goto Github PK

View Code? Open in Web Editor NEW

This project forked from martinger/stand-alone-axial-attention

0.0 0.0 0.0 396 KB

Pytorch implementation of Axial-DeepLab: Stand-Alone Axial-Attention for Panoptic Segmentation

Python 3.92% Jupyter Notebook 96.08%

stand-alone-axial-attention's Introduction

Stand-Alone-Axial-Attention

This is a pytorch implementation of the paper Axial-DeepLab: Stand-Alone Axial-Attention for Panoptic Segmentation by Huiyu Wang, Yukun Zhu, Bradley Green, Hartwig Adam, Alan Yuille and Liang-Chieh Chen.

Method

This paper implements the attention mechanism into different ResNet architectures.

Global Self-Attention on images is subject to the problem, that it can only be applied after significant spatial downsampling of the input. Every pixels relation is calculated to every other pixel so learning gets computationally very expensive, which prevents its usage across all layers in a fully attentional model.

In this paper the authors migitate this issue by introducing their Axial-Attention concept, where the attention mechanism related to one pixel is applied in two steps, vertically and horizontally:

axial

Furthermore they extend the positional encoding from query-pixels also to the keys and values.

axial formula

Axial

Implementation details

I only tested the implementation with ResNet50 for now. The used ResNet V1.5 architectures are adapted from https://github.com/pytorch/vision/blob/master/torchvision/models/resnet.py

The paper notes In order to avoid careful initialization of WQ, WK, WV , rq, rk, rv, we use batch normalizations in all attention layers. Consequently two batch normalization layers are applied.

Additional Parameters:

  • attention: ResNet stages in which you would like to apply the attention layers
  • num_heads: Number of attention heads
  • kernel_size: Maximum local field on which Axial-Attention is applied
  • inference: Allows to inspect the attention weights of a trained model

Example

See the jupyter notebook or the example training script

Requirements

stand-alone-axial-attention's People

Contributors

martinger 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.