Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
学習済み Caffe モデルを移植してみた
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
ohtysk
December 19, 2015
66k
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
学習済み Caffe モデルを移植してみた
ohtysk
December 19, 2015
More Decks by ohtysk
See All by ohtysk
20170408_cvsaisentan_39_ohtysk
ohtysk
0
1.3k
20161203_cvsaisentan_ECCV2016
ohtysk
0
630
Featured
See All Featured
We Are The Robots
honzajavorek
0
400
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
850
Speed Design
sergeychernyshev
33
2.2k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
Bioeconomy Workshop: Dr. Julius Ecuru, Opportunities for a Bioeconomy in West Africa
akademiya2063
PRO
1
410
So, you think you're a good person
axbom
PRO
2
2.2k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.6k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2.2k
Measuring & Analyzing Core Web Vitals
bluesmoon
9
1k
Neural Spatial Audio Processing for Sound Field Analysis and Control
skoyamalab
0
570
Transcript
学習済み Caffe モデルを 移植して使ってみた 2015/12/19 @ohtysk 1
自己紹介 • twitter id: @ohtysk • メーカ勤務 研究・開発 ソフトウエアエンジニア 画像処理
• python, DNN, Chainer 初心者(勉強中) • 「人工知能は人間を越えるか」「深層学習」読了 2
背景 • 動機:実績のある学習済みモデルを使って CNN の性能を向上したい • Chainer には学習済み Caffe モデルを利用するしくみがある
• しかし上記の仕組みは個人的には以下のような課題がある • 記述が独自で学習コストとコード量が増大する • Caffe モデルの読み込みに時間がかかる => そこで Caffe モデルを Chainer モデルに移植して使ってみた 3
移植のステップ ① caffemodel/prototxt をダウンロード a. 「caffe modelzoo」でぐぐると出てくる ② caffemodel ファイルから
hdf5 ファイルを作成(詳細は後述) ③ caffemodel に対応する Chain クラスを作成(詳細は後述) a. ここが少し手間なので将来的には自動生成できるとうれしいですね! b. alexnet, googlenet などについては chainer/examples/imagenet に既にある! ④ 作成した Chain オブジェクトに hdf5 データをロード(詳細は後述) 4
全体像 5 Caffe Model Zoo alexnet.caffemodel train.prototxt deply.prototxt local machine
alexnet.caffemodel train.prototxt deply.prototxt ①download alexnet.h5 alex.py ②convert internet network.png ③visualize network ③create ③create ④load
②caffemodel ファイルから hdf5 ファイルを作成 import chainer.functions.caffe as c import chainer.serializers
as s func = c.CaffeFunction(“alexnet.caffemodel”) # caffemodel 読み込み。遅い! s.save_hdf5(“alexnet.h5”, func) # hdf5 ファイルに保存。簡単! 6
• 右図のような Chain クラスを定義 • __init__ で link を定義 •
__call__で link, function を接続 • ヒント • ②の func を調べる • prototxt を読む • ネットワーク図を見る(caffe/python/draw_net.py で作成可能) ③caffemodel に対応する Chain クラスを定義 7 図1Chain クラス例 図2 ネットワーク図例 ex) dir(func) func.layers func.forwards func[‘conv1’]
④作成した Chain オブジェクトにデータをロード import alex # caffemodelに対応した Chain クラスをインポート import
chainer.serializers as s model = alex.Alex() # Chain オブジェクトを作成 s.load_hdf5(“alexnet.h5”, model) # 学習済みデータをロード。早い! (中略) s.save_hdf5(“alexnet2.h5”, model) # 必要なら再学習済みのデータを保存 8
結果 9 • bvlc_alexnet を移植して再学習した結果 • 記述が統一され学習コストとコード量増大を抑制 • 読み込み時間短縮 182sec
-> 2.7sec • ゼロからの学習と再学習の比較結果 • 再学習の方が学習が進みやすい傾向 • 再学習の方が正解率が高まる傾向 • chainer/examples/imagenet/alex.py と若干の差異が見つかった
まとめ • Caffe モデルの Chainer 移植方法について説明 • 実際に移植した結果、移植の利点を実感 • 今後
caffemodel/prototxt から Chain クラスを自動生成できるといいですね 学習済み Caffe モデルを移植して Happy Chainer Life を! 10