caffe均值文件的设置
(1)可以直接直接导入.tonpy的文件
a.现在将均值文件转化为npy的格式
#!/usr/bin/env python-- mean.binaryproto to python mean.npy file
import numpy as np
import sys,caffe
#装换成python能够识别的一种均值文件的格式需要caffe
root='/home/pengshan/caffe/' #root
mean_proto_path=root+'data/sy1/train_mean.binaryproto' #mean.binaryproto road
mean_npy_path=root+'data/sy1/train_mean.npy' #mean.npy road
blob=caffe.proto.caffe_pb2.BlobProto() #protobuf blob
data=open(mean_proto_path,'rb').read() #mean.binaryproto
blob.ParseFromString(data) #blob
array=np.array(caffe.io.blobproto_to_array(blob))
mean_npy=array[0]
np.save(mean_npy_path,mean_npy)
b.图片预处理的时候,放在均值的相应位置
import numpy as np
mean_file = 'data/CarDataSet/CarCreate/train_mean.npy'
transformer.set_mean('data', np.load(mean_file)) #mean_file为npy文件的路径
(2)可以直接写入数值,然后再导入
在图片预处理的时候:
transformer.set_mean('data',np.array([129.92238600656736,39.10555619302714,4.3888219052695865])) #减去均值
卷积、池化、反卷积的计算