caffe python wrapper

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/laoxuan2011/article/details/52561707

caffe python wrapper

Load some useful libraries:

import os
import numpy as np
import matplotlib.pyplot as plt
%matplotlib inline

List the system path

import sys
sys.path

Import caffe package

import caffe

Then, set the computation mode CPU or GPU

caffe.set_mode_cpu()
#or
#caffe.set_device(0)
#caffe.set_mode_gpu()

Create a network and load weights

net_model_file='./test.prototxt'
net_weights='./snapshot/train_iter_106000.caffemodel'
#load the model
net = caffe.Net(net_model_file,net_weights,caffe.TEST)

The net.params are a list of [weight biases]

#weight in the conv1 layer
net.params['conv1'][0].data
#biases in the conv1 layer
net.params['conv1'][1].data

猜你喜欢

转载自blog.csdn.net/laoxuan2011/article/details/52561707