Giter Site home page Giter Site logo

generalization-vision's Introduction

Generalization Analysis

Setup

Download and install the project:

git clone https://github.com/bdvllrs/FewShotComparison.git
cd FewShotComparison
pip install --user -e .

Pretrained models

All pretrained models should be placed in $TORCH_HOME/checkpoints.

The default for $TORCH_HOME is ~/.cache/torch. You can set the $TORCH_HOME environment variable to update it.

Adversarially Robust models

Download MadryLab's robust pre-trained models for ImageNet here:

https://github.com/MadryLab/robustness#pretrained-models

Here we use the 3 ImageNet trained models:

BiT models

Download the BiT models here:

https://storage.googleapis.com/bit_models/BiT-M-R50x1.npz

Configuration

The config file is located in config/main.yaml. Update the path of the datasets.

Tasks

Start the different generalization tasks from the tasks folder. The tasks will create folders in the results folder with the id of the experiment. It will contain the results and checkpoints.

Few-shot learning task

python few_shot.py

Parameters:

  • --models (list[str]) list of the models to use. Defaults to all models.
  • --ntrials (int) number of repetitions per experiment. Defaults to 10.
  • --batch_size (int) batch size. Defaults to 64.
  • --load_results (int) id of a previous experiment to load and continue.
  • --override_models (list[str]) if a previous experiment is loaded, list of models that had already been computed to recompute. Defaults to none.

Unsupervised clustering task

python unsupervised_clustering.py

Parameters:

  • --models (list[str]) list of the models to use. Defaults to all models.
  • --batch_size (int) batch size. Defaults to 64.
  • --load_results (int) id of a previous experiment to load and continue.
  • --override_models (list[str]) if a previous experiment is loaded, list of models that had already been computed to recompute. Defaults to none.

Transfer learning task

python transfer_learning.py

Parameters:

  • --models (list[str]) list of the models to use. Defaults to all models.
  • --lr (float) learning rate. Defaults to 1e-3.
  • --n_workers (int) number of workers to use. Defaults to 0.
  • --n_epochs (int) number of epochs to compute. Defaults to 20.
  • --batch_size (int) batch size. Defaults to 64.
  • --load_results (int) id of a previous experiment to load and continue.
  • --override_models (list[str]) if a previous experiment is loaded, list of models that had already been computed to recompute. Defaults to none.

Model Comparison

python correlations_models.py

Parameters:

  • --models (list[str]) list of the models to use. Defaults to all models.
  • --batch_size (int) batch size. Defaults to 64.
  • --rdm_distance_metric (str) among t-test, cosine, correlation. Distance metric to use to compute the RDMs. Defaults to t-test.
  • --rda_correlation_type (str) among pearson, spearman and kendall. Correlation function to use to correlate the RDMs. Defaults to spearson.
  • --load_results (int) id of a previous experiment to load and continue.
  • --override_models (list[str]) if a previous experiment is loaded, list of models that had already been computed to recompute. Defaults to none.

Skip-Grams

python word2vec.py

Parameters:

  • --models (list[str]) list of the models to use. Defaults to all models.
  • --batch_size (int) batch size. Defaults to 64.
  • --nepochs (int) number of epochs to train. Defaults to 5.
  • --vocab_size (int) size of the vocabulary to use, not counting the visual words. Defaults to 20,000.
  • --emb_dimension (int) dimension of the embeddings vectors. Visual word embeddings will be reduced using a PCA. If -1, the embedding size will be determined by the embedding size of the visual word embeddings. Defaults to 300.
  • --window_size (int) Gensim's window_size parameter. Defaults to 5.
  • --save_dir path to save the word embeddings to.
  • --load_dir path to load the word embeddings from in the case of evaluating the word embeddings.
  • --load_results (int) id of a previous experiment to load and continue.
  • --override_models (list[str]) if a previous experiment is loaded, list of models that had already been computed to recompute. Defaults to none.

generalization-vision's People

Contributors

bdvllrs avatar

Stargazers

 avatar

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.