LoginSignup
9
8

More than 5 years have passed since last update.

CaffeのモデルをTensorFlowで使う

Last updated at Posted at 2017-08-09

Chainerには、caffe.CaffeFunction('bvlc_googlenet.caffemodel')のようにcaffemodelを読み込む関数が備わっています。

参考: http://qiita.com/tabe2314/items/6c0c1b769e12ab1e2614

普段TensorFlowしか使ってないので、そういう便利系のやつがTensorFlowにもないかと調べていたらありました。

ethereon/caffe-tensorflow: Caffe models in TensorFlow - GitHub

この中のconvert.pyを使えば、.prototxt.caffemodelを、TensorFlowで使われる.py.npyに変換できます。

.prototxt.pyはモデルの構造、.caffemodel.npyは重みデータです。

使い方

examples/mnistが変換に関する説明になっています。

NN構造データの変換(.prototxt.py

$ ./convert.py examples/mnist/lenet.prototxt --code-output-path=mynet.py

重みデータの変換(.caffemodel.npy

$ ./convert.py examples/mnist/lenet.prototxt --caffemodel examples/mnist/lenet_iter_10000.caffemodel --data-output-path=mynet.npy
9
8
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
9
8