Skip to content

Conversation

tdomhan
Copy link
Contributor

@tdomhan tdomhan commented Feb 25, 2014

This is basically an adopted version of the conv layer kernel visualization from: https://code.google.com/p/cuda-convnet/source/browse/trunk/shownet.py

Here's for example the first layer of the imagenet model, that's available for download:
out

Aravindh Mahendran and others added 30 commits February 18, 2014 00:49
Add TanH = hyperbolic tangent activation layer (popular for sparse
autoencoders).
Generalize architectures to arbitrary DAGs by split layers
Set leveldb options.max_open_files = 100 and Fix BVLC#13 and BVLC#38
@kloudkl
Copy link
Contributor

kloudkl commented Feb 25, 2014

That's great! Until now, we almost have everything that cuda-convnet provided and many more that it did not.

Considering the work in #142, this is better placed in tools/extra and renamed to something like visualize_conv_layer.py.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look at the note about main function by @Yangqing in #107.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, please use a main function. Thank you.

@sergeyk
Copy link
Contributor

sergeyk commented Feb 25, 2014

Pinging @longjon who's been working on related things.

@shelhamer
Copy link
Member

Please rebase on the latest dev and file this in tools/extras or work it into the imagenet example at examples/imagenet for merge. Thanks!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably import pyplot (e.g., import matplotlib.pyplot as plt) instead of pylab, as the latter is really meant for interactive work (see http://matplotlib.org/faq/usage_faq.html#matplotlib-pylab-and-pyplot-how-are-they-related).

@longjon
Copy link
Contributor

longjon commented Feb 26, 2014

It would be nice to follow the docstring convention of the existing Python code (i.e., omit the first blank line), and more generally to follow PEP8 / the Google Python style guide (e.g., stick to an 80 character line width).

@longjon
Copy link
Contributor

longjon commented Feb 26, 2014

I'm also slightly concerned about reading the protobuf file using the Python protobuf wrapper -- even though it ought to be just as good as in C++, in practice it's slower, and can fail for very large files (including Alex-sized nets). So, I'd prefer if this code used pycaffe directly to read the net (i.e., by constructing a CaffeNet), and then used that interface to access the parameters; this would also mean this code wouldn't care about the underlying file format. (On the other hand, there is something to be said for being able to examine the net without any compiled dependency; but I think that will be more frustrating than it is worth.)

@sergeyk
Copy link
Contributor

sergeyk commented Feb 26, 2014

I second Jon's suggestions.

@Yangqing
Copy link
Member

I would like to point out my earlier visualization codes at decaf:

https://github.com/UCB-ICSI-Vision-Group/decaf-release/blob/master/decaf/util/visualize.py

which should have almost everything you need. A visualization in the decaf
days is at:

http://nbviewer.ipython.org/github/UCB-ICSI-Vision-Group/decaf-release/blob/master/decaf/demos/notebooks/lena_imagenet.ipynb

Yangqing

On Wed, Feb 26, 2014 at 2:36 AM, Sergey Karayev [email protected]:

I second Jon's suggestions.

Reply to this email directly or view it on GitHubhttps://github.com//pull/158#issuecomment-36112008
.

@tdomhan
Copy link
Contributor Author

tdomhan commented Feb 27, 2014

Thanks for the input everyone. I'll pep8-ify the code and move it to tools/extra.

@Yangqing nice! I hadn't seen the decaf visualizations yet.

@longjon have you had bigger problems with the python protobuf. For me everything worked smoothly so far. That is the imagenet model loaded really quickly and I didn't experience any crashes so far.

@longjon
Copy link
Contributor

longjon commented Feb 28, 2014

Indeed, it's really slow for me. This is using protoc version 2.5.0. Do you see different behavior?

In [1]: from caffe.proto import caffe_pb2

In [2]: net = caffe_pb2.NetParameter()

In [3]: with open('/u/vis/jonlong/alexnet_train_iter_470000') as f:
   ...:     data = f.read()
   ...:     

In [4]: %time net.ParseFromString(data)
CPU times: user 2min 55s, sys: 1.12 s, total: 2min 56s
Wall time: 2min 56s

In [5]: from caffe import pycaffe

In [6]: %time pycaffe.CaffeNet('/u/vis/jonlong/caffe/examples/imagenet_deploy.prototxt', '/u/vis/jonlong/alexnet_train_iter_470000')
CPU times: user 1.26 s, sys: 313 ms, total: 1.57 s
Wall time: 1.83 s
Out[6]: <caffe.pycaffe.CaffeNet at 0x63da680>

@shelhamer
Copy link
Member

I too have had terrible luck with python protobuf support.

I recommend reading the params through the python net interface: net.params()[idx].data for param blob at index idx. You might model your contribution after Yangqing's decaf example, which is a nice illustration of the filters and responses.

@Yangqing
Copy link
Member

Python protobuf is quite slow indeed, esp with large protobuf values. So
for large files you might want to use the C interface unless it's easier to
code up in python - balance between coding time and run time :)

There is a fast python protobuf (essentially wrapper around C) but you may
need to install it separately, AFAIK it does not come with pip.

Yangqing

On Thu, Feb 27, 2014 at 4:09 PM, Evan Shelhamer [email protected]:

I too have had terrible luck with python protobuf support.

I recommend reading the params through the python net interface. You might
model your contribution after Yangqing's decaf example, which is a nice
illustration of the filters and responses.

Reply to this email directly or view it on GitHubhttps://github.com//pull/158#issuecomment-36307978
.

@shelhamer
Copy link
Member

@tdomhan thanks for the visualization proposal, but due to the implementation details cited in this thread, @longjon will port the DeCAF visualization demo in #207.

@shelhamer shelhamer closed this Mar 13, 2014
@tdomhan
Copy link
Contributor Author

tdomhan commented Mar 15, 2014

no worries. I'm looking forward to @longjon 's visualizations then.

lukeyeager pushed a commit to lukeyeager/caffe that referenced this pull request Jun 8, 2016
Use cuDNN routine FindEx to find the best algorithm.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants