tensorflow / lucid

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

import vgg16 #167

Closed najingligong1111 closed 5 years ago

najingligong1111 commented 5 years ago
import numpy as np
import tensorflow as tf

import lucid.modelzoo.vision_models as models
from lucid.misc.io import show
import lucid.optvis.objectives as objectives
import lucid.optvis.param as param
import lucid.optvis.render as render
import lucid.optvis.transform as transform

model = models.InceptionV1()
model.load_graphdef()

how to change to vgg16?

models.VGG16()
najingligong1111 commented 5 years ago
from lucid.modelzoo.other_models import  *  

ImportErrorTraceback (most recent call last)
<ipython-input-31-73e16add7239> in <module>()
      1 
      2 from lucid.modelzoo.util  import   forget_xy ,load_graphdef
----> 3 from lucid.modelzoo.other_models import  *

ImportError: No module named other_models

or

ImportErrorTraceback (most recent call last)
<ipython-input-32-8947b524c42d> in <module>()
      1 
      2 from lucid.modelzoo.util  import   forget_xy ,load_graphdef
----> 3 from lucid.modelzoo.other_models.AlexNet  import  AlexNet

ImportError: No module named other_models.AlexNet
from lucid.modelzoo.other_models.AlexNet import AlexNet
colah commented 5 years ago

(edited question to separate code and text)

colah commented 5 years ago

Hi! You want this:

import lucid.modelzoo.vision_models as models

model = models.VGG16_caffe()
model.load_graphdef()

The _caffe is because there are multiple implementations of VGG floating around.

You may find it helpful to look at the modelzoo notebook.

Good luck with your experiments!

najingligong1111 commented 5 years ago
ucid.modelzoo.vision_models as 

AttributeErrorTraceback (most recent call last)

in () 1 ----> 2 model = models.VGG16_caffe() 3 model.load_graphdef()

AttributeError: 'module' object has no attribute 'VGG16_caffe'

colah commented 5 years ago

Hm. I'd guess you're using an old version of lucid. Could you try doing this?

import pkg_resources
pkg_resources.get_distribution("lucid").version
najingligong1111 commented 5 years ago

Hm. I'd guess you're using an old version of lucid. Could you try doing this?

import pkg_resources
pkg_resources.get_distribution("lucid").version

https://colab.research.google.com/github/tensorflow/lucid/blob/master/notebooks/tutorial.ipynb 0.1.5 https://colab.research.google.com/github/tensorflow/lucid/blob/master/notebooks/modelzoo.ipynb 0.2.3 and it is ok in the bellow . the upper dont work.

colah commented 5 years ago

Great, glad you got it working! I'd recommend trying to use recent versions of lucid.

najingligong1111 commented 5 years ago

Great, glad you got it working! I'd recommend trying to use recent versions of lucid.

thank you , great work you have done!