Enhancing Few-shot Image Classification with Cosine Transformer

Quang-Huy Nguyen, Cuong Q. Nguyen, Dung D. Le, Hieu H. Pham
11/13/2022
cs.CV
transformer-attention

Official code: vinuni-vishc/Few-Shot-Cosine-Transformer (32 stars, Python, last commit 2024-04-13).

Abstract

This paper addresses the few-shot image classification problem, where the classification task is performed on unlabeled query samples given a small amount of labeled support samples only. One major challenge of the few-shot learning problem is the large variety of object visual appearances that prevents the support samples to represent that object comprehensively.

Show full abstract

This might result in a significant difference between support and query samples, therefore undermining the performance of few-shot algorithms. In this paper, we tackle the problem by proposing Few-shot Cosine Transformer (FS-CT), where the relational map between supports and queries is effectively obtained for the few-shot tasks. The FS-CT consists of two parts, a learnable prototypical embedding network to obtain categorical representations from support samples with hard cases, and a transformer encoder to effectively achieve the relational map from two different support and query samples. We introduce Cosine Attention, a more robust and stable attention module that enhances the transformer module significantly and therefore improves FS-CT performance from 5% to over 20% in accuracy compared to the default scaled dot-product mechanism. Our method performs competitive results in mini-ImageNet, CUB-200, and CIFAR-FS on 1-shot learning and 5-shot learning tasks across backbones and few-shot configurations. We also developed a custom few-shot dataset for Yoga pose recognition to demonstrate the potential of our algorithm for practical application. Our FS-CT with cosine attention is a lightweight, simple few-shot algorithm that can be applied for a wide range of applications, such as healthcare, medical, and security surveillance. The official implementation code of our Few-shot Cosine Transformer is available at https://github.com/vinuni-vishc/Few-Shot-Cosine-Transformer

View on arXivView PDF

Code Implementations(1)

Few shot learning for human pose estimation

326Python, ShellJul 2, 20222 years agoNOASSERTION

Similar Papers

Cite this paper

@article{nguyen2022enhancing,
  title  = {Enhancing Few-shot Image Classification with Cosine Transformer},
  author = {Quang-Huy Nguyen and Cuong Q. Nguyen and Dung D. Le and Hieu H. Pham},
  year   = {2022},
  eprint = {2211.06828},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2211.06828}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2211.06828.svg)](https://codeofpaper.com/paper/2211.06828)

Discussion