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
620
Featured
See All Featured
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
56k
Easily Structure & Communicate Ideas using Wireframe
afnizarnur
194
17k
Fireside Chat
paigeccino
43
4k
Skip the Path - Find Your Career Trail
mkilby
1
240
Music & Morning Musume
bryan
48
7.4k
AI Search: Implications for SEO and How to Move Forward - #ShenzhenSEOConference
aleyda
1
1.4k
Public Speaking Without Barfing On Your Shoes - THAT 2023
reverentgeek
1
570
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
840
Speed Design
sergeychernyshev
33
2.1k
The innovator’s Mindset - Leading Through an Era of Exponential Change - McGill University 2025
jdejongh
PRO
1
350
[Rails World 2026] Durable orchestration on Rails: from continuation to workflow
palkan
1
380
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
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