A collection of differentiable SVD methods and also the official implementation of the ICCV21 paper "Why Approximate Matrix Square Root Outperforms Accurate SVD in Global Covariance Pooling?"
This repository contains:
You can also find the presentation of our work via the slides and via the poster.
In this paper, we investigate the reason behind why approximate matrix square root calculated via Newton-Schulz iteration outperform the accurate ones computed by SVD from the perspectives of data precision and gradient smoothness. Various remedies for
computing smooth SVD gradients are investigated. We also propose a new spectral meta-layer that uses SVD in the forward pass, and Pad\’e approximants in the backward propagation to compute the gradients. The results of the so-called SVD-Pad\’e achieve state-of-the-art results on ImageNet and FGVC datasets.
As the backward algorithm of SVD is prone to have numerical instability, we implement a variety of end-to-end SVD methods by manipulating the backward algortihms in this repository. They include:
In the task of global covaraince pooling, the SVD-Pad\’e achieves the best performances. You are free to try other methods in your research.
The codes is modifed on the basis of iSQRT-COV.
See the requirements.txt for the specific required packages.
To train AlexNet on ImageNet, choose a spectral meta-layer in the script and run:
CUDA_VISIBLE_DEVICES=0,1 bash train_alexnet.sh
The pre-trained models of ResNet-50 with SVD-Pad\’e is available via Google Drive. You can load the state dict by:
model.load_state_dict(torch.load('pade_resnet50.pth.tar'))
The proposed Scaling Eigen Branch (SEB) is implemented here, and the training scripts are available here.
The pre-trained models are available via Google Drive.
The perturbation-based visualization results are available via Google Drive, and the back-propagation-based visualizations are available via Google Drive. We use torchray to generate backward-based explanations.
If you think the codes is helpful to your research, please consider citing our paper:
@inproceedings{song2021approximate,
title={Why Approximate Matrix Square Root Outperforms Accurate SVD in Global Covariance Pooling?},
author={Song, Yue and Sebe, Nicu and Wang, Wei},
booktitle={ICCV},
year={2021}
}
@article{song2022eigenvalues,
title={On the Eigenvalues of Global Covariance Pooling for Fine-grained Visual Recognition},
author={Song, Yue and Sebe, Nicu and Wang, Wei},
journal={IEEE TPAMI},
year={2022},
publisher={IEEE}
}
If you have any questions or suggestions, please feel free to contact me