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}
}
You might also like...
MASA-SR: Matching Acceleration and Spatial Adaptation for Reference-Based Image Super-Resolution (CVPR2021)

MASA-SR Official PyTorch implementation of our CVPR2021 paper MASA-SR: Matching Acceleration and Spatial Adaptation for Reference-Based Image Super-Re

Interpretation of T cell states using reference single-cell atlases
Interpretation of T cell states using reference single-cell atlases

Interpretation of T cell states using reference single-cell atlases ProjecTILs is a computational method to project scRNA-seq data into reference sing

Code for C2-Matching (CVPR2021). Paper: Robust Reference-based Super-Resolution via C2-Matching.
Code for C2-Matching (CVPR2021). Paper: Robust Reference-based Super-Resolution via C2-Matching.

C2-Matching (CVPR2021) This repository contains the implementation of the following paper: Robust Reference-based Super-Resolution via C2-Matching Yum

A embed able annotation tool for end to end cross document co-reference
A embed able annotation tool for end to end cross document co-reference

CoRefi CoRefi is an emebedable web component and stand alone suite for exaughstive Within Document and Cross Document Coreference Anntoation. For a de

This is the official repo for TransFill:  Reference-guided Image Inpainting by Merging Multiple Color and Spatial Transformations at CVPR'21. According to some product reasons, we are not planning to release the training/testing codes and models. However, we will release the dataset and the scripts to prepare the dataset. Reference code for the paper CAMS: Color-Aware Multi-Style Transfer.
Reference code for the paper CAMS: Color-Aware Multi-Style Transfer.

CAMS: Color-Aware Multi-Style Transfer Mahmoud Afifi1, Abdullah Abuolaim*1, Mostafa Hussien*2, Marcus A. Brubaker1, Michael S. Brown1 1York University

Pip-package for trajectory benchmarking from "Be your own Benchmark: No-Reference Trajectory Metric on Registered Point Clouds", ECMR'21

Map Metrics for Trajectory Quality Map metrics toolkit provides a set of metrics to quantitatively evaluate trajectory quality via estimating consiste

EFENet: Reference-based Video Super-Resolution with Enhanced Flow Estimation

EFENet EFENet: Reference-based Video Super-Resolution with Enhanced Flow Estimation Code is a bit messy now. I woud clean up soon. For training the EF

YouRefIt: Embodied Reference Understanding with Language and Gesture
YouRefIt: Embodied Reference Understanding with Language and Gesture

YouRefIt: Embodied Reference Understanding with Language and Gesture YouRefIt: Embodied Reference Understanding with Language and Gesture by Yixin Che

Comments
  • How to speed up the loop in build_with_representer_proxy_batch

    How to speed up the loop in build_with_representer_proxy_batch

    Hi, thank you very much for providing the code! I've installed jax with CUDA, so now solving the kernel_fn is faster. However, the build_with_representer_proxy_batch is still quite slow, I assume it is due to the solve_bilevel_opt_representer_proxy, which requires calculating the implicit gradient, or is it because of something else? Is there a way to make the computation faster? Thank you!

    opened by pipilurj 1
Owner
Zalán Borsos
PhD student at ETH Zurich
Zalán Borsos
A mini library for Policy Gradients with Parameter-based Exploration, with reference implementation of the ClipUp optimizer from NNAISENSE.

PGPElib A mini library for Policy Gradients with Parameter-based Exploration [1] and friends. This library serves as a clean re-implementation of the

NNAISENSE 56 Jan 1, 2023
Fast, modular reference implementation of Instance Segmentation and Object Detection algorithms in PyTorch.

Faster R-CNN and Mask R-CNN in PyTorch 1.0 maskrcnn-benchmark has been deprecated. Please see detectron2, which includes implementations for all model

Facebook Research 9k Jan 4, 2023
Reference implementation of code generation projects from Facebook AI Research. General toolkit to apply machine learning to code, from dataset creation to model training and evaluation. Comes with pretrained models.

This repository is a toolkit to do machine learning for programming languages. It implements tokenization, dataset preprocessing, model training and m

Facebook Research 408 Jan 1, 2023
Simple reference implementation of GraphSAGE.

Reference PyTorch GraphSAGE Implementation Author: William L. Hamilton Basic reference PyTorch implementation of GraphSAGE. This reference implementat

William L Hamilton 861 Jan 6, 2023
[CVPR 2022] Official PyTorch Implementation for "Reference-based Video Super-Resolution Using Multi-Camera Video Triplets"

Reference-based Video Super-Resolution (RefVSR) Official PyTorch Implementation of the CVPR 2022 Paper Project | arXiv | RealMCVSR Dataset This repo c

Junyong Lee 151 Dec 30, 2022
Intel® Nervana™ reference deep learning framework committed to best performance on all hardware

DISCONTINUATION OF PROJECT. This project will no longer be maintained by Intel. Intel will not provide or guarantee development of or support for this

Nervana 3.9k Dec 20, 2022
Image morphing without reference points by applying warp maps and optimizing over them.

Differentiable Morphing Image morphing without reference points by applying warp maps and optimizing over them. Differentiable Morphing is machine lea

Alex K 380 Dec 19, 2022
Intel® Nervana™ reference deep learning framework committed to best performance on all hardware

DISCONTINUATION OF PROJECT. This project will no longer be maintained by Intel. Intel will not provide or guarantee development of or support for this

Nervana 3.9k Feb 9, 2021