Code Monkey home page Code Monkey logo

shine's Introduction

MDEQ - SHINE

This is the second part of the code for the paper "SHINE: SHaring the INverse Estimate from the forward pass for bi-level optimization and implicit models", submitted at the 2022 ICLR conference. The first part of the code to reproduce the Bi-level optimizations experiments is available here. This source code allows to reproduce the experiments on multiscale DEQs, i.e. Figure 3, and Figure E.2. in Appendix. This repo is based on the original mdeq repo by @jerrybai1995.

General instructions

You need Python 3.7 or above to run this code. This code will only run on a computer equipped with a GPU. You can then install the requirements with: pip install -r requirements.txt.

Reproducing Figure 3, DEQ

You can reproduce Figure 3 of the paper with the following sequence of scripts:

# cifar
python paper_trainings.py
python paper_backward_times.py
# imagenet
python paper_trainings.py --dataset imagenet --n_runs 1 --refines 0,5,None
python paper_backward_times.py --dataset imagenet
python paper_plot.py

You can further indicate how many gpus to use in each script with the --n_gpus option (default for training is 4). You can find other options using the --help option. Beware:

  • each CIFAR training is 11hours to 15 hours long (100 of them by default)
  • each ImageNet training is 3 days to 7 days long (6 of them by default)

For a practical reproduction you might want to run those in an HPC (i.e. change line 56-60 to work with e.g. submitit). For a test use, you can use the --n_runs (the number of repetitions for the error bar) and --n_refines (the number of points on the Pareto curve) options.

You can also just do the CIFAR trainings, by simply not running the ImageNet ones. The Figure will still be generated.

Reproducing Figure E.2., Quality of the inversion using OPA in DEQs

You can reproduce Figure E.2. of the paper with the following script:

python mdeq_lib/tests/modules/adj_broyden_correl.py

This should take about 15 mins to run with a single GPU.

shine's People

Contributors

jerrybai1995 avatar zaccharieramzi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

nguyennhan1992

shine's Issues

Weird bug in Figure

Traceback (most recent call last):
  File "paper_plot.py", line 193, in <module>
    fig.savefig('fig4.pdf', dpi=300);
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/figure.py", line 2959, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/backend_bases.py", line 2230, in print_figure
    self.figure.draw(renderer)
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/artist.py", line 74, in draw_wrapper
    result = draw(artist, renderer, *args, **kwargs)
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/artist.py", line 51, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/figure.py", line 2735, in draw
    renderer, self, artists, self.suppressComposite)
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/image.py", line 132, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/artist.py", line 51, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/_api/deprecation.py", line 431, in wrapper
    return func(*inner_args, **inner_kwargs)
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/axes/_base.py", line 2925, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/image.py", line 132, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/artist.py", line 51, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/axis.py", line 1132, in draw
    renderer)
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/axis.py", line 1058, in _get_tick_bboxes
    for tick in ticks if tick.label1.get_visible()],
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/axis.py", line 1058, in <listcomp>
    for tick in ticks if tick.label1.get_visible()],
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/text.py", line 903, in get_window_extent
    bbox, info, descent = self._get_layout(self._renderer)
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/text.py", line 315, in _get_layout
    clean_line, self._fontproperties, ismath=ismath)
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/backends/_backend_pdf_ps.py", line 89, in get_text_width_height_descent
    s, fontsize, renderer=self)
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/texmanager.py", line 401, in get_text_width_height_descent
    page, = dvi
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/dviread.py", line 251, in __iter__
    while self._read():
  File "/home/zaccharie/workspace/shine/venv/lib/python3.7/site-packages/matplotlib/dviread.py", line 330, in _read
    byte = self.file.read(1)[0]
IndexError: index out of range

When using science plots (i.e. with Latex)

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.