# 编写一个函数,将二进制的均值转换为python的均值 def convert_mean(binMean,npyMean): blob = caffe.proto.caffe_pb2.BlobProto() bin_mean = open(binMean, 'rb' ).read() blob.ParseFromString(bin_mean) arr = np.array( caffe.io.blobproto_to_array(blob) ) npy_mean = arr[0] np.save(npyMean, npy_mean ) # 调用函数转换均值 binMean='examples/cifar10/mean.binaryproto' npyMean='examples/cifar10/mean.npy' convert_mean(binMean,npyMean)