Created
May 10, 2016 01:04
-
-
Save jeffdonahue/e67bf4ed8b8f1c4dfadbb99009d593a1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# usage: python count_caffemodel_params.py /path/to/my.caffemodel [/path/to/my/other.caffemodel, ...] | |
from caffe.proto import caffe_pb2 | |
import sys | |
assert len(sys.argv) >= 2 | |
for caffemodel_filename in sys.argv[1:]: | |
with open(caffemodel_filename, 'r') as caffemodel_file: | |
caffemodel = caffemodel_file.read() | |
net = caffe_pb2.NetParameter() | |
net.ParseFromString(caffemodel) | |
param_count = 0 | |
for layer in net.layer: | |
for blob in layer.blobs: | |
param_count += len(blob.data) | |
print '%s: %d parameters' % (caffemodel_filename, param_count) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment