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
68
時短勤務で東名阪3拠点以上の大規模スクラム LeSS Huge のスクラムマスターをしたときの話 & リモートワークっていいよね
niwasawa
1
1.4k
Google Home 用アプリをリリースして起きたこと七つ
niwasawa
0
1.4k
My three gadgets of Java
niwasawa
0
2k
Androidアプリのリリースがわりとさくっとできたのでメモを残す
niwasawa
0
870
コードを1行も書かずに iOS アプリをリリースできるのか?
niwasawa
0
1.2k
経路を案内する地図
niwasawa
1
650
iOS 11 Social Framework is dead! To the Twitter Kit!!
niwasawa
0
1.2k
地図とマインクラフトで現実世界の夢を見る
niwasawa
0
1.1k
Other Decks in Programming
See All in Programming
print("Hello, World")
eddie
2
530
Ruby×iOSアプリ開発 ~共に歩んだエコシステムの物語~
temoki
0
350
Platformに“ちょうどいい”責務ってどこ? 関心の熱さにあわせて考える、責務分担のプラクティス
estie
1
140
How Android Uses Data Structures Behind The Scenes
l2hyunwoo
0
480
MCPとデザインシステムに立脚したデザインと実装の融合
yukukotani
4
1.5k
Amazon RDS 向けに提供されている MCP Server と仕組みを調べてみた/jawsug-okayama-2025-aurora-mcp
takahashiikki
1
120
CJK and Unicode From a PHP Committer
youkidearitai
PRO
0
110
go test -json そして testing.T.Attr / Kyoto.go #63
utgwkk
3
320
パッケージ設計の黒魔術/Kyoto.go#63
lufia
3
440
Kiroで始めるAI-DLC
kaonash
2
630
複雑なフォームに立ち向かう Next.js の技術選定
macchiitaka
2
240
デザイナーが Androidエンジニアに 挑戦してみた
874wokiite
0
550
Featured
See All Featured
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Build The Right Thing And Hit Your Dates
maggiecrowley
37
2.9k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.5k
How to Think Like a Performance Engineer
csswizardry
26
1.9k
Art, The Web, and Tiny UX
lynnandtonic
303
21k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
248
1.3M
Producing Creativity
orderedlist
PRO
347
40k
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.4k
The Straight Up "How To Draw Better" Workshop
denniskardys
236
140k
Principles of Awesome APIs and How to Build Them.
keavy
126
17k
How to Ace a Technical Interview
jacobian
279
23k
Fireside Chat
paigeccino
39
3.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