tensorflow / lucid

A collection of infrastructure and tools for research in neural network interpretability.
Apache License 2.0
4.67k stars 653 forks source link

Adding More Models to Modelzoo #86

Closed colah closed 5 years ago

colah commented 6 years ago

I'd really like get more models into lucid modelzoo.

Background

It seems like there are two major reservoirs of pre-trained models: tf slim and caffe. Most pre-trained models online come from one of those. In many cases, there are two different pre-trained models going by the same name floating around, because both projects re-implemented the model. (tf-hub seems to mostly be repackaging a subset of the tf-slim models.)

Typically, neither of these sources is the canonical model.

Questions / Considerations

Should we really be creating another model zoo, or is there a way we could just pull from an existing one?

How do we deal with multiple different implementations of the "same" model?

It would be really nice to have the same model trained on multiple datasets for some experiments

What meta-data should we be including about models?

colah commented 6 years ago

Initial work on importing models (eg. AlexNet and InceptionV3) in #85.

colah commented 6 years ago

Workflows for importing models

Slim -> Frozen

I've checked in some scripts that seem to work in #86 (lucid/scratch/scripts/import_slim/).

Caffe -> Frozen (caffe-tensorflow)

One solution is caffe-tensorflow which now has a --standalone-output-path for directly crating frozen models (see ethereon/caffe-tensorflow#76).

Getting this to work reliably takes a number of tricks, including using an old tensorflow version, running a caffe model update script, and manually cleaning up temp files.

I've checked in some scripts that seem to work in #86 (lucid/scratch/scripts/import_caffe/).

Caffe -> Frozen (MMdnn)

Microsoft's new MMdnn tool is also a promising way to convert models to TensorFlow. There was an issue (Microsoft/MMdnn#117) where someone was trying to do Caffe -> Frozen like we want to.

colah commented 6 years ago

Modelzoo Resources

Eventually, it would be nice to have a list of models with:

colah commented 6 years ago

I've been trying to mass export the tensorflow slim models. It appears that some of the provided checkpoints are not compatible with their present code (tensorflow/models#4938).

On the plus side, I have successfully exported 8 more models! :) (Update: now available in #85.)

colah commented 6 years ago

Also, I've got several mostrostities of an ipython-bash fusion script to automatically export models from tf-slim to us. Uh, is that some we'd want to... check in somewhere?? @ludwigschubert ?

More generally, the workflows for getting models from different formats into something sane is full of gotchas and workarounds. For now, I'm using this issue as a bit of a log, but it would be good to have institutional memory about how to do this.

ludwigschubert commented 6 years ago

My writeup was/is in this notebook, primarily because I wanted it to be easy for users to put in their own graph and still follow the steps. Let's merge both of our attempts when you have reached a plateau in adding new models.

colah commented 6 years ago

Update: merged #85, adding more models

Despite there likely being some bugs slipping through, I've merged #85. It adds many more models, both from tf-slim and caffe (see list below).

Some potential problems -- at the moment, I'm inferring all of these from the convention of the framework the model was trained in, but this may not be reliable:

There are more caffe models that we did not merge.

In addition to the models, the new PR adds scripts at lucid/scratch/scripts/import_slim and lucid/scratch/scripts/import_caffe demonstrating how to import models of those types.

TF Slim Models

Caffe Models