This is the reference implementation for "Coresets via Bilevel Optimization for Continual Learning and Streaming"

Overview

Coresets via Bilevel Optimization

This is the reference implementation for "Coresets via Bilevel Optimization for Continual Learning and Streaming" https://arxiv.org/pdf/2006.03875.pdf.

This repository also contains the implementation of the selection via Nyström proxy used for selecting batches in "Semi-supervised Batch Active Learning via Bilevel Optimization" https://arxiv.org/pdf/2010.09654. Selection via the Nyström proxy supports data augmentation, it is faster for larger coresets and hence supersedes the representer proxy in data summarization scenarios.

Overview

To get started with the library, check out demo.ipynb Open In Colab that shows how to build coresets for a toy regression problem and for MNIST classification. The following snippet outlines the general usage:

import bilevel_coreset
import loss_utils
import numpy as np

x, y = load_data()

# define proxy kernel function
linear_kernel_fn = lambda x1, x2: np.dot(x1, x2.T)

coreset_size = 10

coreset_constructor = bilevel_coreset.BilevelCoreset(outer_loss_fn=loss_utils.cross_entropy,
                                                    inner_loss_fn=loss_utils.cross_entropy,
                                                    out_dim=y.shape[1])
coreset_inds, coreset_weights = coreset_constructor.build_with_representer_proxy_batch(x, y, 
                                                    coreset_size, linear_kernel_fn, inner_reg=1e-3)
x_coreset, y_coreset = x[coreset_inds], y[coreset_inds]

Note: if you are planning to use the library on your problem, the most important hyperparameter to tune is inner_reg, the regularizer of the inner objective in the representer proxy - try the grid [10-2, 10-3, 10-4, 10-5, 10-6].

Requirements

Python 3 is required. To install the required dependencies, run:

pip install -r requirements.txt

If you are planning to use the NTK proxy, consider installing the GPU version of JAX: instructions here. If you would like to run the experiments, add the project root to your PYTHONPATH env variable.

Data Summarization

Change dir to data_summarization. For running and plotting the MNIST summarization experiment, adjust the globals in runner.py to your setup and run:

python runner.py --exp cnn_mnist
python plotter.py --exp cnn_mnist

Similarly, for the CIFAR-10 summary for a version of ResNet-18 run:

python runner.py --exp resnet_cifar
python plotter.py --exp resnet_cifar

For running the Kernel Ridge Regression experiment, you first need to generate the kernel with python generate_cntk.py. Note: this implementation differs in the kernel choice in generate_kernel() from the paper. For details on the original kernel, please refer to the paper. Once you generated the kernel, generate the results by:

python runner.py --exp krr_cifar
python plotter.py --exp krr_cifar 

Continual Learning and Streaming

We showcase the usage our coreset construction in continual learning and streaming with memory replay. The buffer regularizer beta is tuned individually for each method. We provide the best betas from [0.01, 0.1, 1.0, 10.0, 100.0, 1000.0] for each method in cl_results/ and streaming_results/.

Running the Experiments

Change dir to cl_streaming. After this, you can run individual experiments, e.g.:

python cl.py --buffer_size 100 --dataset splitmnist --seed 0 --method coreset --beta 100.0

You can also run the continual learning and streaming experiments with grid search over beta on datasets derived from MNIST by adjusting the globals in runner.py to your setup and running:

python runner.py --exp cl
python runner.py --exp streaming
python runner.py --exp imbalanced_streaming

The table of result can be displayed by running python process_results.py with the corresponding --exp argument. For example, python process_results.py --exp imbalanced_streaming produces:

Method \ Dataset splitmnistimbalanced
reservoir 80.60 +- 4.36
cbrs 89.71 +- 1.31
coreset 92.30 +- 0.23

The experiments derived from CIFAR-10 can be similarly run by:

python cifar_runner.py --exp cl
python process_results --exp splitcifar
python cifar_runner.py --exp imbalanced_streaming
python process_results --exp imbalanced_streaming_cifar

Selection via the Nyström proxy

The Nyström proxy was proposed to support data augmentations. It is also faster for larger coresets than the representer proxy. An example of running the selection on CIFAR-10 can be found in batch_active_learning/nystrom_example.py.

Citation

If you use the code in a publication, please cite the paper:

@article{borsos2020coresets,
      title={Coresets via Bilevel Optimization for Continual Learning and Streaming}, 
      author={Zalán Borsos and Mojmír Mutný and Andreas Krause},
      year={2020},
      journal={arXiv preprint arXiv:2006.03875}
}
Owner
Zalán Borsos
PhD student at ETH Zurich
Zalán Borsos
[CVPR 2021] MetaSAug: Meta Semantic Augmentation for Long-Tailed Visual Recognition

MetaSAug: Meta Semantic Augmentation for Long-Tailed Visual Recognition (CVPR 2021) arXiv Prerequisite PyTorch = 1.2.0 Python3 torchvision PIL argpar

51 Nov 11, 2022
This is the official code for the paper "Ad2Attack: Adaptive Adversarial Attack for Real-Time UAV Tracking".

Ad^2Attack:Adaptive Adversarial Attack on Real-Time UAV Tracking Demo video 📹 Our video on bilibili demonstrates the test results of Ad^2Attack on se

Intelligent Vision for Robotics in Complex Environment 10 Nov 07, 2022
Its a Plant Leaf Disease Detection System based on Machine Learning.

My_Project_Code Its a Plant Leaf Disease Detection System based on Machine Learning. I have used Tomato Leaves Dataset from kaggle. This system detect

Sanskriti Sidola 3 Jun 15, 2022
UNAVOIDS: Unsupervised and Nonparametric Approach for Visualizing Outliers and Invariant Detection Scoring

UNAVOIDS: Unsupervised and Nonparametric Approach for Visualizing Outliers and Invariant Detection Scoring Code Summary aggregate.py: this script aggr

1 Dec 28, 2021
Official code for On Path Integration of Grid Cells: Group Representation and Isotropic Scaling (NeurIPS 2021)

On Path Integration of Grid Cells: Group Representation and Isotropic Scaling This repo contains the official implementation for the paper On Path Int

Ruiqi Gao 39 Nov 10, 2022
Python Library for Signal/Image Data Analysis with Transport Methods

PyTransKit Python Transport Based Signal Processing Toolkit Website and documentation: https://pytranskit.readthedocs.io/ Installation The library cou

24 Dec 23, 2022
Torch-based tool for quantizing high-dimensional vectors using additive codebooks

Trainable multi-codebook quantization This repository implements a utility for use with PyTorch, and ideally GPUs, for training an efficient quantizer

Daniel Povey 41 Jan 07, 2023
Bayesian Image Reconstruction using Deep Generative Models

Bayesian Image Reconstruction using Deep Generative Models R. Marinescu, D. Moyer, P. Golland For technical inquiries, please create a Github issue. F

Razvan Valentin Marinescu 51 Nov 23, 2022
PyTorch code for our paper "Gated Multiple Feedback Network for Image Super-Resolution" (BMVC2019)

Gated Multiple Feedback Network for Image Super-Resolution This repository contains the PyTorch implementation for the proposed GMFN [arXiv]. The fram

Qilei Li 66 Nov 03, 2022
Fast and robust clustering of point clouds generated with a Velodyne sensor.

Depth Clustering This is a fast and robust algorithm to segment point clouds taken with Velodyne sensor into objects. It works with all available Velo

Photogrammetry & Robotics Bonn 957 Dec 21, 2022
Maximum Spatial Perturbation for Image-to-Image Translation (Official Implementation)

MSPC for I2I This repository is by Yanwu Xu and contains the PyTorch source code to reproduce the experiments in our CVPR2022 paper Maximum Spatial Pe

51 Dec 14, 2022
Official code for Score-Based Generative Modeling through Stochastic Differential Equations

Score-Based Generative Modeling through Stochastic Differential Equations This repo contains the official implementation for the paper Score-Based Gen

Yang Song 818 Jan 06, 2023
Easy-to-use micro-wrappers for Gym and PettingZoo based RL Environments

SuperSuit introduces a collection of small functions which can wrap reinforcement learning environments to do preprocessing ('microwrappers'). We supp

Farama Foundation 357 Jan 06, 2023
A large-scale video dataset for the training and evaluation of 3D human pose estimation models

ASPset-510 (Australian Sports Pose Dataset) is a large-scale video dataset for the training and evaluation of 3D human pose estimation models. It contains 17 different amateur subjects performing 30

Aiden Nibali 25 Jun 20, 2021
Machine learning notebooks in different subjects optimized to run in google collaboratory

Notebooks Name Description Category Link Training pix2pix This notebook shows a simple pipeline for training pix2pix on a simple dataset. Most of the

Zaid Alyafeai 363 Dec 06, 2022
TuckER: Tensor Factorization for Knowledge Graph Completion

TuckER: Tensor Factorization for Knowledge Graph Completion This codebase contains PyTorch implementation of the paper: TuckER: Tensor Factorization f

Ivana Balazevic 296 Dec 06, 2022
Repo for EMNLP 2021 paper "Beyond Preserved Accuracy: Evaluating Loyalty and Robustness of BERT Compression"

beyond-preserved-accuracy Repo for EMNLP 2021 paper "Beyond Preserved Accuracy: Evaluating Loyalty and Robustness of BERT Compression" How to implemen

Kevin Canwen Xu 10 Dec 23, 2022
Azion the best solution of Edge Computing in the world.

Azion Edge Function docker action Create or update an Edge Functions on Azion Edge Nodes. The domain name is the key for decision to a create or updat

8 Jul 16, 2022
A super lightweight Lagrangian model for calculating millions of trajectories using ERA5 data

Easy-ERA5-Trck Easy-ERA5-Trck Galleries Install Usage Repository Structure Module Files Version iteration Easy-ERA5-Trck is a super lightweight Lagran

Zhenning Li 26 Nov 19, 2022
Contextual Attention Localization for Offline Handwritten Text Recognition

CALText This repository contains the source code for CALText model introduced in "CALText: Contextual Attention Localization for Offline Handwritten T

0 Feb 17, 2022