如何将.npy文件转换为.binaryproto? [英] How to convert .npy file into .binaryproto?

查看:74
本文介绍了如何将.npy文件转换为.binaryproto?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用python创建了一个平均图像文件,并将其保存到numpy文件中。我想知道如何将这个.npy文件转换成.binaryproto文件。我正在使用此文件来使用GoogLeNet进行训练。

I have created a mean image file using python and saved it into numpy file. I would like to know how I could convert this .npy file into .binaryproto file. I am using this file to train using the GoogLeNet.

推荐答案

您可以简单地使用numpy来创建.binaryproto和给定的caffe io函数

You can simply use numpy to creat the .binaryproto and the given caffe io functions

import caffe
#avg_img is your numpy array with the average data 
blob = caffe.io.array_to_blobproto( avg_img)
with open( mean.binaryproto, 'wb' ) as f :
    f.write( blob.SerializeToString())

这篇关于如何将.npy文件转换为.binaryproto?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆