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.2k
ゼロから作る Deep Learningを Ruby で
ゼロから作る
Deep Learningを
Ruby で
niwasawa
May 12, 2017
Tweet
Share
More Decks by niwasawa
See All by niwasawa
Flashで地図
niwasawa
0
56
時短勤務で東名阪3拠点以上の大規模スクラム LeSS Huge のスクラムマスターをしたときの話 & リモートワークっていいよね
niwasawa
1
1.2k
Google Home 用アプリをリリースして起きたこと七つ
niwasawa
0
1.3k
My three gadgets of Java
niwasawa
0
1.8k
Androidアプリのリリースがわりとさくっとできたのでメモを残す
niwasawa
0
720
コードを1行も書かずに iOS アプリをリリースできるのか?
niwasawa
0
1k
経路を案内する地図
niwasawa
1
560
iOS 11 Social Framework is dead! To the Twitter Kit!!
niwasawa
0
1k
地図とマインクラフトで現実世界の夢を見る
niwasawa
0
870
Other Decks in Programming
See All in Programming
MetricKitで予期せぬ終了を検知する話 / Detect unexpected termination with MetricKit
nekowen
1
190
ONE WEDGE_company_guide
1wedge_one
0
480
Elm 0.19.0 Changes
bkuhlmann
0
490
Zero Waste, Radical Magic, and Italian Graft – Quarkus Efficiency Secrets
hollycummins
0
230
SwiftUIで使いやすいToastの作り方 / How to build a Toast system which is easy to use in SwiftUI
lovee
3
140
Netty Chicago Java User Group 2024-04-17
sullis
0
170
MicrosoftのPlatform Engineeringガイドを読んで実際になにかやってみた
ymd65536
1
330
ゆるい個人開発のススメ
kuroppe1819
10
990
VSCodeでのDatabricks開発もお勧めしたい/I would also recommend Databricks development with VSCode.
kazumain
0
250
GraphQLサーバの構成要素を整理する #ハッカー鮨 #tsukijigraphql / graphql server technology selection
izumin5210
4
840
Goのmultiple errorsについて (2024年4月版)
syumai
3
810
PostmanでAPIの動作確認が楽になった話
h455h1
0
170
Featured
See All Featured
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
6
1.5k
Music & Morning Musume
bryan
41
5.6k
Visualization
eitanlees
136
14k
Product Roadmaps are Hard
iamctodd
44
9.7k
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
17
1.4k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
20
1.9k
Put a Button on it: Removing Barriers to Going Fast.
kastner
58
3.1k
GraphQLとの向き合い方2022年版
quramy
32
12k
Reflections from 52 weeks, 52 projects
jeffersonlam
345
19k
Why You Should Never Use an ORM
jnunemaker
PRO
51
8.6k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
2
3.4k
Bootstrapping a Software Product
garrettdimon
PRO
302
110k
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