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
ゼロから作る Deep Learningを Ruby で
Search
niwasawa
May 12, 2017
Programming
0
1.3k
ゼロから作る Deep Learningを Ruby で
ゼロから作る
Deep Learningを
Ruby で
niwasawa
May 12, 2017
Tweet
Share
More Decks by niwasawa
See All by niwasawa
Flashで地図
niwasawa
0
62
時短勤務で東名阪3拠点以上の大規模スクラム LeSS Huge のスクラムマスターをしたときの話 & リモートワークっていいよね
niwasawa
1
1.4k
Google Home 用アプリをリリースして起きたこと七つ
niwasawa
0
1.4k
My three gadgets of Java
niwasawa
0
2k
Androidアプリのリリースがわりとさくっとできたのでメモを残す
niwasawa
0
850
コードを1行も書かずに iOS アプリをリリースできるのか?
niwasawa
0
1.2k
経路を案内する地図
niwasawa
1
640
iOS 11 Social Framework is dead! To the Twitter Kit!!
niwasawa
0
1.2k
地図とマインクラフトで現実世界の夢を見る
niwasawa
0
1k
Other Decks in Programming
See All in Programming
TypeScript LSP の今までとこれから
quramy
1
480
統一感のある Go コードを生成 AI の力で手にいれる
otakakot
0
2.9k
FastMCPでMCPサーバー/クライアントを構築してみる
ttnyt8701
2
130
「ElixirでIoT!!」のこれまでとこれから
takasehideki
0
340
技術懸念に立ち向かい 法改正を穏便に乗り切った話
pop_cashew
0
1.3k
TypeScript を活かしてデザインシステム MCP を作る / #tskaigi_after_night
izumin5210
5
520
エラーって何種類あるの?
kajitack
5
100
從零到一:搭建你的第一個 Observability 平台
blueswen
1
810
セキュリティマネジャー廃止とクラウドネイティブ型サンドボックス活用
kazumura
1
160
eBPFを用いたAIネットワーク監視システム論文の実装 / eBPF Japan Meetup #4
yuukit
3
740
iOSアプリ開発で 関数型プログラミングを実現する The Composable Architectureの紹介
yimajo
2
200
Javaに鉄道指向プログラミング (Railway Oriented Pro gramming) のエッセンスを取り入れる/Bringing the Essence of Railway-Oriented Programming to Java
cocet33000
2
530
Featured
See All Featured
The Illustrated Children's Guide to Kubernetes
chrisshort
48
50k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
657
60k
Faster Mobile Websites
deanohume
307
31k
Typedesign – Prime Four
hannesfritz
42
2.7k
GraphQLの誤解/rethinking-graphql
sonatard
71
11k
VelocityConf: Rendering Performance Case Studies
addyosmani
329
24k
Six Lessons from altMBA
skipperchong
28
3.8k
A designer walks into a library…
pauljervisheath
206
24k
Build The Right Thing And Hit Your Dates
maggiecrowley
36
2.7k
Unsuck your backbone
ammeep
671
58k
Mobile First: as difficult as doing things right
swwweet
223
9.6k
Transcript
θϩ͔Β࡞Δ Deep LearningΛ Ruby Ͱ Naoki Iwasawa @niwasawa
ݸਓతʹࠓRuby Λֶͼ͍ͨͱࢥͬ ͍ͯͨͷͰ͕͢
ػցֶशք۾ Python ͔Γ
θϩ͔Β࡞Δ Deep Learning ͷίʔυ Python
RubyͰॻ͖͍ͨ
ͳͥRubyͰػցֶश ͕ྲྀߦΒͳ͍ͷ͔
ϥΠϒϥϦͱใ͕ἧͬ ͯͳ͍͔Β (´ʀТʀʆ)
θϩ͔Β࡞ΔDeep Learning Ͱ͍ͬͯΔ ֎෦ϥΠϒϥϦ
ܭࢉͷ NumPy ͱ άϥϑඳըͷ Matplotlib ͚ͩ
RubyͰ͍͚Δ ͷͰ
ͬͯΈͨ
θϩ͔Β࡞Δ Deep Learning 1ষ
sinؔͱcosؔ ͷάϥϑΛඳ͘
Python vs Ruby
import numpy as np import matplotlib matplotlib.use("AGG") # ඳըϥΠϒϥϦʹAGG(Anti-Grain Geometry)Λ͏
import matplotlib.pyplot as plt # σʔλͷ࡞ x = np.arange(0, 6, 0.1) # 0͔Β6·Ͱ0.1ࠁΈͰੜ y1 = np.sin(x) y2 = np.cos(x) # άϥϑͷඳը plt.figure(figsize=(4, 3), dpi=160) # ը૾αΠζ plt.plot(x, y1, label="sin") plt.plot(x, y2, linestyle = "--", label="cos") # ഁઢͰඳը plt.xlabel("x") # x࣠ͷϥϕϧ plt.ylabel("y") # y࣠ͷϥϕϧ plt.title("sin & cos") # λΠτϧ plt.legend() plt.savefig("python_graph.png")
require 'numo/narray' require 'numo/gnuplot' # σʔλͷ࡞ x = Numo::DFloat.new(60).seq(0, 0.1)
# 0͔Β6·Ͱ0.1ࠁΈͰੜ y1 = Numo::DFloat::Math.sin(x) y2 = Numo::DFloat::Math.cos(x) # άϥϑͷඳը g = Numo::gnuplot do set term: {png: {size: [640, 480]}} # ը૾αΠζ set output: 'ruby_graph.png' set title: 'sin \& cos' # λΠτϧ set key: 'box left bottom' set offset: [0, 0, 0, 0] plot x, y1, {w: 'lines', lw: 3, title: 'sin'}, x, y2, {w: 'lines', lw: 3, title: 'cos'} end
Python
Ruby
RubyͰΘΓͱ ͍͚ͦ͏
Python Ͱ ܭࢉ NumPy άϥϑඳը Matplotlib
Ruby Ͱ ܭࢉ Numo::NArray άϥϑඳը Numo::Gnuplot
RubyͰػցֶशʹ͑Δ ϥΠϒϥϦσϑΝΫ τελϯμʔυ͕ͳ͍ ͠ใ͕গͳ͍
ࠓճ৽͠ͷϥΠϒ ϥϦ Numo::NArray ͱ Numo::Gnuplot ͕ྑͦ͞͏ ͩͬͨͷͰͬͯΈͨ
Numo ެࣜαΠτʹ ʮ!!! under development !!!ʯ ͱॻ͔Ε͍ͯΔ
https://github.com/ruby-numo/numo/blob/master/README.md
։ൃதʁ ෆ҆ఆʁ (((((ʀƅЧƅ))))) ͜Θ͍
·͋ಈ͍͍ͯΔ͔ Β͍͍͔ͳɻɻɻ
θϩ͔Β࡞Δ Deep Learning 2ষ
ύʔηϓτϩϯ ʹΑΔཧճ࿏
Python vs Ruby
import numpy as np def AND(x1, x2): x = np.array([x1,
x2]) w = np.array([0.5, 0.5]) # ॏΈ b = -0.7 # όΠΞε tmp = np.sum(w*x) + b if tmp <= 0: return 0 else: return 1
require 'numo/narray' def AND(x1, x2) x = Numo::DFloat[x1, x2] w
= Numo::DFloat[0.5, 0.5] # ॏΈ b = -0.7 # όΠΞε tmp = (w*x).sum + b if tmp <= 0 0 else 1 end end
࣮ߦ݁Ռ $ python and_gate.py (0, 0) -> 0 (1, 0)
-> 0 (0, 1) -> 0 (1, 1) -> 1 $ ruby and_gate.rb [0, 0] -> 0 [1, 0] -> 0 [0, 1] -> 0 [1, 1] -> 1
RubyͰେৎ
ࠓRubyͰػցֶ श͠·͠ΐ͏( ´∀ʆ)
ࠓճͷιʔείʔυ Qiita Ͱެ։தɻ Python vs Ruby ʰθϩ͔Β࡞ΔDeep Learningʱ 1ষ sinؔͱcosؔ
ͷάϥϑ - Qiita http://qiita.com/niwasawa/items/6d9aba43f3cdba5ca725 Python vs Ruby ʰθϩ͔Β࡞ΔDeep Learningʱ 2ষ ύʔηϓτϩϯ ʹΑΔཧճ࿏ - Qiita http://qiita.com/niwasawa/items/73f604f956d043671f39 Naoki Iwasawa @niwasawa