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
860
コードを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
1.1k
Other Decks in Programming
See All in Programming
ruby.wasmで多人数リアルタイム通信ゲームを作ろう
lnit
3
480
0626 Findy Product Manager LT Night_高田スライド_speaker deck用
mana_takada
0
170
Discover Metal 4
rei315
2
140
Porting a visionOS App to Android XR
akkeylab
0
460
第9回 情シス転職ミートアップ 株式会社IVRy(アイブリー)の紹介
ivry_presentationmaterials
1
320
Azure AI Foundryではじめてのマルチエージェントワークフロー
seosoft
0
170
AIと”コードの評価関数”を共有する / Share the "code evaluation function" with AI
euglena1215
1
170
技術同人誌をMCP Serverにしてみた
74th
1
650
Hypervel - A Coroutine Framework for Laravel Artisans
albertcht
1
130
PipeCDのプラグイン化で目指すところ
warashi
1
280
脱Riverpod?fqueryで考える、TanStack Queryライクなアーキテクチャの可能性
ostk0069
0
140
10 Costly Database Performance Mistakes (And How To Fix Them)
andyatkinson
0
340
Featured
See All Featured
Testing 201, or: Great Expectations
jmmastey
43
7.6k
Documentation Writing (for coders)
carmenintech
72
4.9k
The Straight Up "How To Draw Better" Workshop
denniskardys
234
140k
The Language of Interfaces
destraynor
158
25k
YesSQL, Process and Tooling at Scale
rocio
173
14k
RailsConf 2023
tenderlove
30
1.1k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.4k
Embracing the Ebb and Flow
colly
86
4.7k
Being A Developer After 40
akosma
90
590k
Build your cross-platform service in a week with App Engine
jlugia
231
18k
The World Runs on Bad Software
bkeepers
PRO
69
11k
Practical Orchestrator
shlominoach
189
11k
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