python读取caffemodel

来源:互联网 发布:淘宝客户端怎么改差评 编辑:程序博客网 时间:2024/06/06 19:37
#coding=utf-8
import caffe
if __name__ == "__main__":
    #文件的存放路径
    root = '/home/xgx/Downloads/resnet-protofiles/'
    caffe.set_mode_cpu
    net = caffe.Net(root+'ResNet_101_deploy.prototxt',root+'ResNet-101-model.caffemodel',caffe.TEST)
    #第一个卷基层的权值
    conv1_w = net.params['conv1'][0].data
    #第一个卷基层的偏置值,前提是有bias项,比如bias_term为false
    conv1_b = net.params['conv1'][1].data
    #可以打印相应的参数和参数的维度等信息
    print conv1_w
    print conv1_b
    print conv1_w.size
原创粉丝点击