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
CSC305 Lecture 01
javiergs
PRO
1
400
なぜGoのジェネリクスはこの形なのか? Featherweight Goが明かす設計の核心
ryotaros
7
1k
どの様にAIエージェントと 協業すべきだったのか?
takefumiyoshii
2
620
なぜあの開発者はDevRelに伴走し続けるのか / Why Does That Developer Keep Running Alongside DevRel?
nrslib
3
380
NetworkXとGNNで学ぶグラフデータ分析入門〜複雑な関係性を解き明かすPythonの力〜
mhrtech
3
1k
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
180
Model Pollution
hschwentner
1
190
ソフトウェア設計の実践的な考え方
masuda220
PRO
3
500
プログラミングどうやる? ~テスト駆動開発から学ぶ達人の型~
a_okui
0
190
CI_CD「健康診断」のススメ。現場でのボトルネック特定から、健康診断を通じた組織的な改善手法
teamlab
PRO
0
190
Goで実践するドメイン駆動開発 AIと歩み始めた新規プロダクト開発の現在地
imkaoru
4
740
Signals & Resource API in Angular: 3 Effective Rules for Your Architecture @BASTA 2025 in Mainz
manfredsteyer
PRO
0
110
Featured
See All Featured
Rails Girls Zürich Keynote
gr2m
95
14k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
9
850
How GitHub (no longer) Works
holman
315
140k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
667
120k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
46
7.6k
[RailsConf 2023] Rails as a piece of cake
palkan
57
5.9k
Bash Introduction
62gerente
615
210k
Why You Should Never Use an ORM
jnunemaker
PRO
59
9.6k
The Art of Programming - Codeland 2020
erikaheidi
56
14k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Fashionably flexible responsive web design (full day workshop)
malarkey
407
66k
Keith and Marios Guide to Fast Websites
keithpitt
411
22k
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