Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
JavaでDeep Learningしよう
Search
radiocat
September 27, 2017
Technology
0
680
JavaでDeep Learningしよう
radiocat
September 27, 2017
Tweet
Share
More Decks by radiocat
See All by radiocat
EMの仕事、あるいは顧客価値創出のアーキテクト
radiocat
0
230
アジャイルを支える心理的安全性の守破離 / Psychological safety for Agile
radiocat
1
800
経験ゼロからはじめる!10年以上続くプロダクトのアウトカム創出戦略 / Challenges of product management
radiocat
1
4.4k
変化の時代に活かす「みんなのプロジェクトマネジメント」 / Utilize project management for change
radiocat
0
1.8k
「中小企業のエンジニアチームを”楽”にする」を目指す組織マネジメントの変わる勇気と変えない勇気 / Challenge to Scrum 4
radiocat
2
3.5k
関西的なノリで変化の波をノリこなすチームの取り組み / 3 Steps and Kansai-soul to Riding the Waves of Change
radiocat
2
3.2k
スクラムちゃうがなと言われてもやってみぃひん? / Challenge to Scrum 3
radiocat
4
9.6k
Re:ゼロから始めるアジャイル開発 / restart agile
radiocat
3
1.6k
スクラム開発について / What is Scrum?
radiocat
0
530
Other Decks in Technology
See All in Technology
ガバメントクラウドの概要と自治体事例(名古屋市)
techniczna
2
240
能登半島災害現場エンジニアクロストーク 【JAWS FESTA 2025 in 金沢】
ditccsugii
0
630
JAZUG 15周年記念 × JAT「AI Agent開発者必見:"今"のOracle技術で拡張するAzure × OCIの共存アーキテクチャ」
shisyu_gaku
1
160
Findy Team+ QAチーム これからのチャレンジ!
findy_eventslides
0
160
Contract One Engineering Unit 紹介資料
sansan33
PRO
0
8.8k
AI Agent Dojo #2 watsonx Orchestrateフローの作成
oniak3ibm
PRO
0
120
新規事業におけるGORM+SQLx併用アーキテクチャ
hacomono
PRO
0
260
AWS Control Tower に学ぶ! IAM Identity Center 権限設計の第一歩 / IAM Identity Center with Control Tower
y___u
0
170
リセラー企業のテクサポ担当が考える、生成 AI 時代のトラブルシュート 2025
kazzpapa3
1
160
Digitization部 紹介資料
sansan33
PRO
1
5.5k
BI ツールはもういらない?Amazon RedShift & MCP Server で試みる新しいデータ分析アプローチ
cdataj
0
160
アイテムレビュー機能導入からの学びと改善
zozotech
PRO
0
150
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
49
14k
Optimizing for Happiness
mojombo
379
70k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.6k
Keith and Marios Guide to Fast Websites
keithpitt
411
23k
Code Reviewing Like a Champion
maltzj
526
40k
Being A Developer After 40
akosma
91
590k
Principles of Awesome APIs and How to Build Them.
keavy
127
17k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
30
2.9k
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
980
Music & Morning Musume
bryan
46
6.8k
Product Roadmaps are Hard
iamctodd
PRO
54
11k
VelocityConf: Rendering Performance Case Studies
addyosmani
332
24k
Transcript
Javaで Deep Learningしよう もくもく発表会 2017.9.27 / @radicoatz
本日のテーマ DL4Jを使ってJavaでも Deep Learningができるよ
「Deep Learning Javaプログラミング」購入 http://amzn.asia/fhPjlzC
読書会に参加 https://osaka-prg-school.connpass.com/event/54057/
まずは 書籍の内容をざっくり紹介
DL以前の基礎知識 1. 人工知能とディープラーニングの変遷 ➢ DL誕生までの歴史的背景について • 人工知能技術の変遷について • 機械学習が直面した問題 •
AIの第一次ブーム〜第三次ブーム • ディープラーニングの誕生 2. 機械学習アルゴリズムを学ぶ - ディープ ラーニングへの準備 ➢ 機械学習の基礎とDL前夜のアルゴリズムに ついて • 教師あり学習と教師なし学習 • サポートベクトルマシン • ニューラルネットワーク • パーセプトロン • 多層パーセプトロン
DLのアルゴリズムの解説 3. ディープラーニング探求 <1> ➢ DLの基本となるアルゴリズムの解説 ➢ 数式の理論とそれをJavaコード化したサンプ ルプログラムの解説 •
ニューラルネットワークの問題点 • ディープビリーフネット • 積層デノイジング・オートエンコーダ 4. ディープラーニング探求 <2> ➢ 前章を発展させたDLアルゴリズムの解説 ➢ 理論とサンプルコードによる解説 • ドロップアウト • 畳み込みニューラルネットワーク • ニューラルネットワーク • パーセプトロン • 多層パーセプトロン
DL4Jの解説/DLの応用と今後の展望 5. JavaライブラリDeeplearning4jの活用 ➢ ライブラリの紹介 ➢ サンプルコードによる実装方法の解説 • DL4JとND4Jの概要 •
ND4Jによる実装 • DL4Jによる実装 6. ディープラーニングの応用と実用化 ◦ DLの活用事例 ◦ DLの課題 7. ディープラーニング探求 <3> ◦ Java以外のライブラリの紹介 8. 今後の動向を展望する ◦ AlphaGoなどの事例 ◦ DL動向の情報源 サンプルコード https://book.impress.co.jp/books/1115101146#box-download https://github.com/radiocat/DLJ
ND4J/DL4Jを使ってみる
DL4J(Deeplearning4j)とは • https://deeplearning4j.org/index.html • JavaのDeepLearningライブラリ • Apache 2.0ライセンスのOSS • CPUとGPUをサポート
• Skymind社が中心となって開発 関連ライブラリ:ND4J(N-Dimensional arrays 4j) • http://nd4j.org/getstarted.html • 行列操作などに使う科学的計算ライブラリ( PythonのNumpyのようなツール) • Numpyの2倍の速さ
サンプルプログラム DL4Jのクイックスタートガイドを参照( https://deeplearning4j.org/ja/quickstart) 必須要件 • Java 7+ • Maven 3.2.5+
• Git(サンプルプログラムの取得) サンプルコードの取得と事前準備 $ git clone
[email protected]
:deeplearning4j/dl4j-examples.git $ cd dl4j-examples/ $ mvn clean install
• 取得したサンプルコードの nd4j-examples フォルダ以下 • 全部で12個のサンプル 行列の定義 • 2行3列のゼロの行列⇒ INDArray
nd1 = Nd4j.zeros(3, 2); • 2行3列⇒ INDArray nd2 = Nd4j.create(new float[][]{{1,2,3},{4,5,6}}); 演算 • 和: INDArray nd3 = nd1.add(nd2); • 差: INDArray nd3 = nd1.sub(nd2); • スカラー: INDArray nd3 = nd1.mul(10); • 内積: INDArray nd3 = nd1.mmul(nd2); ND4J
DL4J • サンプルコードの dl4j-examples フォルダ以下 • 豊富なサンプル DLのモデル構築に集中できるフレームワーク • 基本的にはNeuralNetConfigurationでBuilderパターンを使う
• CSVや画像からベクトルへの変換はフレームワークがサポート • UIツールもある https://deeplearning4j.org/ja/visualization その他の特徴 • Apache Spark対応 https://deeplearning4j.org/spark • Kotlinでの実装 https://github.com/deeplearning4j/dl4j-examples/tree/master/dl4j-examples • Androidへのビルド https://deeplearning4j.org/android
おなじみMNIST(MLPMnistSingleLayerExample) MultiLayerConfiguration conf = new NeuralNetConfiguration.Builder() .seed(rngSeed) //include a random
seed for reproducibility // use stochastic gradient descent as an optimization algorithm .optimizationAlgo(OptimizationAlgorithm.STOCHASTIC_GRADIENT_DESCENT) .iterations(1) .learningRate(0.006) //specify the learning rate .updater(Updater.NESTEROVS) .regularization(true).l2(1e-4) .list() .layer(0, new DenseLayer.Builder() //create the first, input layer with xavier initialization .nIn(numRows * numColumns) .nOut(1000) .activation(Activation.RELU) .weightInit(WeightInit.XAVIER) .build()) .layer(1, new OutputLayer.Builder(LossFunction.NEGATIVELOGLIKELIHOOD) //create hidden layer .nIn(1000) .nOut(outputNum) .activation(Activation.SOFTMAX) .weightInit(WeightInit.XAVIER) .build()) .pretrain(false).backprop(true) //use backpropagation to adjust weights .build(); TensorFlowの場合:https://github.com/tensorflow/tensorflow/blob/r1.3/tensorflow/examples/tutorials/mnist/mnist_softmax.py
まとめ • Javaのコードが書ければDLのモデルを構築できる • CSVや画像データの入力、行列演算などよく使う処理はフレームワークが提供してくれる • CUP/GPU対応など他のライブラリと比較してパフォーマンスも充分出せる • 難しい数式を書く必要はない •
DLのアルゴリズムの知識とモデル構築の設計力は必要 • 新しいアルゴリズムにも随時追従している • 困ったらSkymind社がサポートしてくれる
DEMO
参考 • Deeplearning4j /https://github.com/deeplearning4j • DeepLearning4Jの紹介 - Qiita / https://qiita.com/wmeddie/items/8f036e3eadfa3e012eed
• MNIST For ML Beginners | TensorFlow /https://www.tensorflow.org/get_started/mnist/beginners • ND4J - Javaでベクトルとか行列を定義する - 覚えたら書く / http://blog.y-yuki.net/entry/2017/01/03/000000 • ブログも書きました ◦ 【勉強会メモ】オオサカプログラミングスクール「 Javaerだらけのディープラーニング研究会 第5章」 - radioc@? / http://radiocat.hatenablog.com/entry/2017/09/20/000000