Giter Club home page Giter Club logo

ranksim-imbalanced-regression's Introduction

RankSim: Ranking Similarity Regularization for Deep Imbalanced Regression

This repository contains the code for the paper:
RankSim: Ranking Similarity Regularization for Deep Imbalanced Regression
Yu Gong, Greg Mori, Fred Tung
ICML 2022
[arXiv] [Paper] [Poster]


RankSim (ranking similarity) regularizer encodes an inductive bias that samples that are closer in label space should also be closer in feature space.

Quick Preview

RankSim regularizer is straightforward to implement, can be computed in closed form, and complementary to conventional imbalanced learning techniques. It has two hyperparameters --- interpolation strength lambda and balancing weight gamma.

def batchwise_ranking_regularizer(features, targets, interp_strength_lambda):
    loss = 0

    # Reduce ties and boost relative representation of infrequent labels by computing the 
    # regularizer over a subset of the batch in which each label appears at most once
    batch_unique_targets = torch.unique(targets)
    if len(batch_unique_targets) < len(targets):
        sampled_indices = []
        for target in batch_unique_targets:
            sampled_indices.append(random.choice((targets == target).nonzero()[:,0]).item())
        x = features[sampled_indices]
        y = targets[sampled_indices]
    else:
        x = features
        y = targets

    # Compute feature similarities for ranking
    xxt = torch.matmul(F.normalize(x.view(x.size(0),-1)), F.normalize(x.view(x.size(0),-1)).permute(1,0))

    # Compute the loss of ranking similarity
    for i in range(len(y)):

        label_ranks = rank_normalised(-torch.abs(y[i] - y).transpose(0,1))
        feature_ranks = TrueRanker.apply(xxt[i].unsqueeze(dim=0), interp_strength_lambda) # differentiable ranking operation, defined in ranking.py
        loss += F.mse_loss(feature_ranks, label_ranks)

    return loss

Usage

Please go into the sub-folder to run experiments for different datasets.

Citation

If you find RankSim helpful, please cite our work:

@InProceedings{gong2022ranksim,
  title={{R}ank{S}im: Ranking Similarity Regularization for Deep Imbalanced Regression},
  author={Gong, Yu and Mori, Greg and Tung, Frederick},
  booktitle={International Conference on Machine Learning (ICML)},
  year={2022}

Acknowledgment

The code is based on Yang et al., Delving into Deep Imbalanced Regression, ICML 2021.

ranksim-imbalanced-regression's People

Contributors

durandtibo avatar yugongg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ranksim-imbalanced-regression's Issues

Why does the similarity function used in the label space adopt negative absolute distance?

Why is the similarity function (sigma^y) used to calculate the similarity matrix (S^y) in the label-space negative absolute distance instead of absolute distance?

As far as I know, the similarity function used in feature space is cosine similarity, which has a range of -1 to 1, where -1 indicates that the two quantities are opposite, 0 indicates that they are orthogonal, and 1 indicates that they are in the same direction.

What problems would it cause if the absolute distance was directly used to calculate the similarity function?
Or, what are the considerations for using the negative absolute distance in the paper?

Thanks :))

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.