GOTOH Shunsuke
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    --- tags: 発表, 機械学習名古屋, Julia, 機械学習 slideOptions: transition: slide --- Julia の紹介<br><small>機械学習のための新言語</small> === <!-- .slide: data-background="#383838" --> 2017/07/02 機械学習 名古屋 第11回勉強会 antimon2(後藤 俊介) <aside class="notes">Julia 良いよ Julia の紹介っ!</aside> --- <!-- .slide: data-background="#383838" --> + :arrow_right: デモ + :small_blue_diamond: 自己紹介 + :small_blue_diamond: Julia とは? + :small_blue_diamond: Julia の高速性 + :small_blue_diamond: Julia で機械学習 --- <!-- .slide: data-background="#383838" --> ## デモ ---- <!-- .slide: data-background="#383838" --> [![http://ec2-54-250-154-44.ap-northeast-1.compute.amazonaws.com:8000/mnist_demo_20170702_MLNGY11.svg](http://ec2-54-250-154-44.ap-northeast-1.compute.amazonaws.com:8000/mnist_demo_20170702_MLNGY11.svg)](http://ec2-54-250-154-44.ap-northeast-1.compute.amazonaws.com:8000) https://goo.gl/mxcaCK [Julia](https://julialang.org/) + [MXNet](https://github.com/dmlc/MXNet.jl) + [Mux](https://github.com/JuliaWeb/Mux.jl) で動いています。 <!-- .element: class="fragment" --> <aside class="notes">このサイトは、<a href="https://regional.rubykaigi.org/nagoya03/" target="_blank">他のイベント</a> のデモ用に作成したものを Julia を利用してリメイクしたものです。しばらくしたら閉じる予定です。</aside> --- <!-- .slide: data-background="#1A7E82" --> + :white_check_mark: デモ + :arrow_right: 自己紹介 + :small_blue_diamond: Julia とは? + :small_blue_diamond: Julia の高速性 + :small_blue_diamond: Julia で機械学習 --- <!-- .slide: data-background="#1A7E82" --> # 自己紹介 ---- <!-- .slide: data-background="#1A7E82" --> ## 自己紹介 + 名前:後藤 俊介 + 所属:有限会社 来栖川電算 + コミュニティ:**[機械学習名古屋](https://machine-learning.connpass.com/)**(主催の1人), Python東海, Ruby東海, … + 言語:**Julia**, Python, Ruby, Scala(勉強中), … + ![Twitter](https://i.imgur.com/HqouMIg.png)<!-- .element: class="plain" style="vertical-align:middle;background:transparent" --> [@antimon2](https://twitter.com/antimon2) / ![Facebook](https://i.imgur.com/01nPd37.png)<!-- .element: class="plain" style="vertical-align:middle;background:transparent" --> [antimon2](https://www.facebook.com/antimon2) + ![Github](https://i.imgur.com/yBKtii5.png)<!-- .element: class="plain" style="vertical-align:middle;background:transparent" --> [antimon2](https://github.com/antimon2/) / ![Qiita](https://i.imgur.com/FxHMi64.png)<!-- .element: class="plain" style="vertical-align:middle;background:transparent" --> [@antimon2](http://qiita.com/antimon2) <aside class="notes">今日は空気を読まずに Julia 良いよ Julia の紹介しますっ</aside> --- <!-- .slide: data-background="#213e98" --> + :white_check_mark: デモ + :white_check_mark: 自己紹介 + :arrow_right: Julia とは? + :small_blue_diamond: Julia の高速性 + :small_blue_diamond: Julia で機械学習 --- <!-- .slide: data-background="#213e98" --> # Julia とは? <aside class="notes">簡単な紹介っ</aside> ---- <!-- .slide: data-background="#213e98" --> [![Julia](https://upload.wikimedia.org/wikipedia/commons/6/69/Julia_prog_language.svg)<!-- .element: style="background:white;max-width:80%" -->](https://julialang.org) ---- <!-- .slide: data-background="#213e98" --> ## Julia とは?(1) + [公式サイト(英語) https://julialang.org](https://julialang.org) + 2017/06/20 に v0.6.0 がリリース! + Python/Ruby/R 等の「いいとこどり」言語! + 科学技術計算に強い! + 動作が速い!(LLVM JIT コンパイル) <aside class="notes">今年中に v1.0 が出る予定っ<br>あとググるときは <code>julialang</code> で!</aside> ---- <!-- .slide: data-background="#213e98" --> ## Julia とは?(2) > + Rのように中身がぐちゃぐちゃでなく、 > + Rubyのように遅くなく、 > + Lispのように原始的またはエレファントでなく、 > + Prologのように変態的なところはなく、 > + Javaのように硬すぎることはなく、 > + Haskellのように抽象的すぎない > > ほどよい言語である <!-- .element: style="font-size:66%" --> 引用元:http://www.slideshare.net/Nikoriks/julia-28059489/8 <!-- .element: style="font-size:71%" --> ---- <!-- .slide: data-background="#213e98" --> ## Julia とは?(3) > + C のように高速だけど、 Ruby のような動的型付言語である > + Lisp のようにプログラムと同等に扱えるマクロがあって、しかも Matlab のような直感的な数式表現もできる > + Python のように総合的なプログラミングができて、 R のように統計処理も得意で、 Perl のように文字列処理もできて、 Matlab のように線形代数もできて、 shell のように複数のプログラムを組み合わせることもできる > + 超初心者にも習得は簡単で、 超上級者の満足にも応えられる > + インタラクティブにも動作して、コンパイルもできる <!-- .element: style="font-size:50%" --> ([Why We Created Julia](http://julialang.org/blog/2012/02/why-we-created-julia) から抜粋・私訳) <!-- .element: style="font-size:71%" --> ---- <!-- .slide: data-background="#213e98" --> ## 主な機能 + [多重ディスパッチ](https://ja.wikipedia.org/wiki/%E5%A4%9A%E9%87%8D%E3%83%87%E3%82%A3%E3%82%B9%E3%83%91%E3%83%83%E3%83%81) + 動的型システム + [並行・並列処理](https://docs.julialang.org/en/stable/manual/parallel-computing/)、コルーチン + 組込パッケージマネージャ ---- <!-- .slide: data-background="#213e98" --> ## 文法・関数 ---- <!-- .slide: data-background="#213e98" --> ### 基本的な演算 ```julia julia> 1 + 2 - 3 * 4 # 四則演算(除算以外) -9 julia> 7 / 5 # `整数 / 整数` の結果は浮動小数 1.4 julia> 7 ÷ 5 # `整数 ÷ 整数` の結果は整数 1 julia> 2 ^ 10 # 冪乗は `^` 1024 julia> 123 & 234 | 345 # 論理積 / 論理和 376 julia> 123 ⊻ 234 # 排他的論理和(==`xor(123, 234)`) 145 ``` <!-- .element: style="font-size:46%" --> <aside class="notes">整数同士の除算は実数になりますっ<br>整数除算演算子 <code>÷</code> が別に存在します(Python の <code>//</code> 相当)っ<br>また冪乗も(<code>**</code> ではなく)<code>^</code> ですっ<br><code>⊻</code> は <code>\veebar</code>+<kbd>Tab</kbd>で変換できますっ<br>ちなみに先ほどの <code>÷</code> も <code>\div</code>+<kbd>Tab</kbd>で(基本的に $TeX$ の書式)っ</aside> ---- <!-- .slide: data-background="#213e98" --> ### 配列 ```julia julia> a = [1, 2, 3, 4, 5] 5-element Array{Int64,1}: 1 2 3 4 5 julia> a[1] # Julia は 1-origin 1 julia> println(a[2:3]) # 範囲指定は両端含む [2, 3] ``` <!-- .element: style="font-size:50%" --> <aside class="notes">1-origin であることに注意すればあとは普通の配列っ<br>あと <code>a:b</code> は範囲(<code>Range</code>)の記法。両端を含む(Ruby の <code>a..b</code> と同じ)っ</aside> ---- <!-- .slide: data-background="#213e98" --> ### 配列の内包表記 (1) ```julia julia> a = [n^2 for n=1:5] 5-element Array{Int64,1}: 1 4 9 16 25 julia> A = [x+10y for y=1:3, x=1:3] 3×3 Array{Int64,2}: 11 12 13 21 22 23 31 32 33 ``` <!-- .element: style="font-size:50%" --> <aside class="notes">内包表記の記法は Python に類似っ<br>かつ、<code>for</code> にカンマ区切りで複数のイテレータを渡すことで2次元以上の配列も作成可能っ</aside> ---- <!-- .slide: data-background="#213e98" --> ### 配列の内包表記 (2) ```julia julia> [(a,b,c) for c=1:15,b=1:15,a=1:15 if a^2+a*b+b^2==c^2] 6-element Array{Tuple{Int64,Int64,Int64},1}: (3, 5, 7) (5, 3, 7) (6, 10, 14) (7, 8, 13) (8, 7, 13) (10, 6, 14) ``` <aside class="notes">Python と同様に <code>if</code> で条件を指定することも可能っ<br>あと Python と同様、<code>[○ for ○=○]</code> を <code>(○ for ○=○)</code> と書くと配列ではなくて <code>Generator</code> が返りますっ</aside> ---- <!-- .slide: data-background="#213e98" --> ### ベクトル ```julia julia> x = [1., 2., 3.]; julia> y = [3., 1., 2.]; julia> x + y # `x .+ y` と書いても同じ(elementwise operation) [4., 3., 5.] julia> x .* y # これは `x * y` と書くとNG [3., 2., 6.] julia> x ⋅ y # 内積(dot積、`dot(x, y)` と書いても同じ) 11.0 julia> x × y # 外積(cross積、`cross(x, y)` と書いても同じ) [1., 7., -5.] ``` <!-- .element: style="font-size:50%" --> <aside class="notes">Julia では実は1次元配列がベクトルの扱いっ<br><code>⋅</code> は <code>\cdot</code>+<kbd>Tab</kbd>、<code>×</code> は <code>\times</code>+<kbd>Tab</kbd>っ<br>あとこれらや先ほどの<code>÷</code>や<code>⊻</code>などのように、ASCIIの範囲を超えたUnicode文字の演算子(そのほとんどが $TeX$ 由来)が Julia にはたくさんあります(他には例えば比較演算子の <code>≤</code> <code>≥</code> や、集合の要素 <code>∈</code> や包含関係 <code>⊆</code> などなど)</aside> ---- <!-- .slide: data-background="#213e98" --> ### 行列 ```julia julia> A = [1 2; 3 4] # この記法は MATLAB/Octave 由来 2×2 Array{Int64,2}: 1 2 3 4 julia> A.' # `○.'` は転置行列の記法(これも MATLAB/Octave 由来) 2×2 Array{Int64,2}: 1 3 2 4 ``` <!-- .element: style="font-size:50%" --> <aside class="notes">Julia では2次元配列が行列の扱いっ</aside> ---- <!-- .slide: data-background="#213e98" --> ### 行列の演算 ```julia julia> A = [1 2; 3 4]; B = [3 0; 0 6]; julia> A + B # A .+ B でも同様 2×2 Array{Int64,2}: 4 2 3 10 julia> A * B # matrix multiply 2×2 Array{Int64,2}: 3 12 9 24 julia> A .* B # elementwise multiply 2×2 Array{Int64,2}: 3 0 0 24 ``` <!-- .element: style="font-size:48%" --> <aside class="notes">行列は<code>*</code> で通常の行列積になりますっこれ便利っ</aside> ---- <!-- .slide: data-background="#213e98" --> ### ブロードキャスト ```python julia> sin(0.1) 0.09983341664682815 julia> sin.([0.1, 0.2, 0.3, 0.4]) 4-element Array{Float64,1}: 0.0998334 0.198669 0.29552 0.389418 julia> [0.1, 0.2, 0.3, 0.4] .^ 2 # => [0.01, 0.04, 0.09, 0.16] ``` <!-- .element: style="font-size:50%" --> <aside class="notes">関数名と <code>(</code> の間に <code>.</code> を置くと、普通の関数を配列に拡張してくれる(ブロードキャスト)っ<br><code>.^</code> のように演算子の前に <code>.</code> を書いても同様(先ほど出た <code>.+</code> <code>.*</code> もブロードキャスト)っ</aside> ---- <!-- .slide: data-background="#213e98" --> ### 関数定義 ```julia julia> f(x) = x^2 + 2x - 1 f (generic function with 1 method) julia> f(1) 2 julia> f.(1:5) # => [2, 7, 14, 23, 34] ``` <aside class="notes">数学のように直感的な記述で関数を定義可能っ<br><code>2x</code>は<code>2*x</code>の省略形、曖昧さがなければリテラルと他の識別子が続く場合などに勝手に乗算と解釈してくれるっ<br>またユーザ定義関数も <code>.</code> をつけて自動的にブロードキャスト対応っ</aside> ---- <!-- .slide: data-background="#213e98" --> ### 有理数・複素数 ```python julia> 1//2 == 0.5 true julia> 1//2 - 1//3 1//6 julia> 1im ^ 2 == -1 true julia> (1.0 + 0.5im) * (2.0 - 3.0im) 3.5 - 2.0im ``` <aside class="notes">有理数・複素数を標準サポート。<br><code>//</code> は有理数除算(結果は有理数)<br><code>im</code> は虚数単位。<br>どちらも四則演算も普通に書けますっ</aside> --- <!-- .slide: data-background="#633978" --> + :white_check_mark: デモ + :white_check_mark: 自己紹介 + :white_check_mark: Julia とは? + :arrow_right: Julia の高速性 + :small_blue_diamond: Julia で機械学習 --- <!-- .slide: data-background="#633978" --> # <small>Julia の</small><br>高速性 <aside class="notes">Julia の『速さ』の紹介っ</aside> ---- <!-- .slide: data-background="#633978" --> ## 公式ベンチマーク + https://julialang.org/benchmarks/ + [![High-Performance JIT Compiler](https://i.imgur.com/rl3JXTF.png)](https://julialang.org/#high-performance-jit-compiler) [High-Performance JIT Compiler](https://julialang.org/#high-performance-jit-compiler) <aside class="notes">公式にも「速いよ!」をウリに出していますっ</aside> ---- <!-- .slide: data-background="#633978" --> ## ベンチマーク実験 + ex1. たらい回し関数 + ex2. 数学問題の求解 <aside class="notes">自分でも実験っ</aside> ---- <!-- .slide: data-background="#633978" --> ### ex1. たらい回し関数 参照: [竹内関数(マッカーシー版)](https://ja.wikipedia.org/wiki/%E7%AB%B9%E5%86%85%E9%96%A2%E6%95%B0#.E3.83.9E.E3.83.83.E3.82.AB.E3.83.BC.E3.82.B7.E3.83.BC.E7.89.88) <aside class="notes">フィボナッチ数列と並ぶ、再帰が適度に複雑なベンチマーク御用達関数っ</aside> ---- <!-- .slide: data-background="#633978" --> Julia でのコード例: ```julia= function tak(x::Int, y::Int, z::Int)::Int if x <= y z else tak(tak(x - 1, y, z), tak(y - 1, z, x), tak(z - 1, x, y)) end end tak(22, 11, 0) # => 11 ``` <aside class="notes">他言語も同様に実装っ</aside> ---- <!-- .slide: data-background="#633978" --> ### ex2. 数学問題 > $a^2 + b^2 = 100c + d$ > $c^2 + d^2 = 100a + b$ > を満たす2桁以下の正整数の組 (a, b, c, d) をすべて求めよ。 <!-- .element: style="text-align:left" --> <aside class="notes">という処理をナイーブに組むとどうなるかというベンチマーク問題っ</aside> ---- <!-- .slide: data-background="#633978" --> Julia でのコード例: ```julia= [(a,b,c,d) for d=1:99,c=1:99,b=1:99,a=1:99 if a^2+b^2==100c+d&&c^2+d^2==100a+b] # => [(12, 33, 12, 33) # (38, 69, 62, 5) # (59, 65, 77, 6) # (62, 5, 38, 69) # (77, 6, 59, 65) # (88, 33, 88, 33)] ``` <aside class="notes">こちらはワンライナーただし <code>for</code> をネスト&フィルター処理。<br>他言語も同様っ</aside> ---- <!-- .slide: data-background="#633978" --> ### 実験環境 + Julia(v0.6.0) + REPL 上で `@time` マクロで時間計測 + Python(v3.6.1) + `time` モジュールを利用 + Haskell(v7.10.2) + GHCi: `:set +s` を利用 + GHC: `import Data.Time` を利用 <aside class="notes">をこのMac(MacOSX 10.11.6 / Core i7 3.1GHz / 16GB Memory)で実施っ</aside> ---- <!-- .slide: data-background="#633978" --> ### 実行結果 実行時間(s) | | Julia | Python | GHCi | GHC | | --- | ----: | -----: | ---: | ---: | | ex1 | 1.78 | 91.67 | 189.05 | 1.44 | | ex2 | 2.63 | 20.66 | 174.26 | 1.40 | ---- <!-- .slide: data-background="#633978" --> + Julia はコンパイル言語並みに速い! + Julia は REPL で実行しても速い! <aside class="notes">最適化オプションを付けた Haskell には負けてますが、GHCi(GHCのREPL)に比べれば断然速い⇒ちょっとした確認をするのにREPLで実行することを考えるとJuliaは使えるっ<br>もちろんこのマイクロベンチマークで全てが分かるわけではないし、もっと複雑な処理でもベンチマークを取るべきでしょう。</aside> --- <!-- .slide: data-background="#872724" --> + :white_check_mark: デモ + :white_check_mark: 自己紹介 + :white_check_mark: Julia とは? + :white_check_mark: Julia の高速性 + :arrow_right: Julia で機械学習 --- <!-- .slide: data-background="#872724" --> # <small>Julia で</small><br>機械学習 <aside class="notes">機械学習系ライブラリと実装例の紹介っ</aside> ---- <!-- .slide: data-background="#872724" --> ## Deep Learning 系ライブラリ + [Knet.jl](https://github.com/denizyuret/Knet.jl)(かなり Julia フレンドリー) + [TensorFlow.jl](https://github.com/malmaud/TensorFlow.jl)([TensorFlow](https://www.tensorflow.org/) のラッパー) + **[MXNet.jl](https://github.com/dmlc/MXNet.jl)**(軽量・効率性・柔軟性がウリ) <aside class="notes">主に Deep Learning 系のライブラリばっかです。<br>他にも <a href="https://github.com/MikeInnes/Flux.jl">Flux.jl</a>(MXNet.jl や Tensorflow.jl を(さらに)ラップ)とかあるみたい。<br>今回は <b>MXNet</b> を利用っ</aside> ---- <!-- .slide: data-background="#872724" --> ## Apache MXNet + http://mxnet.io/ + [GitHub Repository](https://github.com/dmlc/mxnet) + [AWS で MXNet](https://aws.amazon.com/jp/mxnet/) <aside class="notes">Julia を初め、多くの言語にネイティブ対応っ<br></aside> ---- <!-- .slide: data-background="#872724" --> ## simple_mlp_with_MXNet.jl (1) ```julia= # Pkg.add("MXNet") using MXNet ``` <aside class="notes">Julia v0.6.0 + MXNet(v0.8.0) だとそのままでは問題があり、現状 <code>Pkg.checkout("MXNet")</code> <code>Pkg.build("MXNet")</code> しないとうまくいかない(2017/06/27 現在)んですけれど省略っ</aside> ---- <!-- .slide: data-background="#872724" --> ## simple_mlp_with_MXNet.jl (2) ```julia=4 mlp = @mx.chain mx.Variable(:data) => mx.FullyConnected(name=:fc1, num_hidden=128) => mx.Activation(name=:relu1, act_type=:relu) => mx.FullyConnected(name=:fc2, num_hidden=64) => mx.Activation(name=:relu2, act_type=:relu) => mx.FullyConnected(name=:fc3, num_hidden=10) => mx.SoftmaxOutput(name=:softmax) ``` <aside class="notes">こんな感じでネットワークが簡単に構築できます(今回MXNetを採用した一番の理由)っ<br>data_provider は省略っ</aside> ---- <!-- .slide: data-background="#872724" --> ## simple_mlp_with_MXNet.jl (3) ```julia=17 # setup model model = mx.FeedForward(mlp, context=mx.cpu()) # optimization algorithm (Momentum SGD) optimizer = mx.SGD(lr=0.1, momentum=0.9) # fit parameters mx.fit(model, optimizer, train_data, n_epoch=20, eval_data=eval_data) ``` <aside class="notes">学習も簡単っ♪<br>optimizer は他に AdaDelta とか AdaGrad とか ADAM とか RMSProp とか色々</aside> ---- <!-- .slide: data-background="#872724" --> [![MXNet_jl06_sample_fitting.png](https://i.imgur.com/SKLf6U8.png)](https://gist.github.com/antimon2/551a5156381d8a667ef17bc0365f6069) ---- <!-- .slide: data-background="#872724" --> ## simple_mlp_with_MXNet.jl (4) ```julia=26 # prediction probs = mx.predict(model, eval_data) # collect all labels from eval data labels = vcat(([label for label in copy(mx.get(eval_data, batch, :softmax_label))] for batch in eval_data)...) # compute the accuracy accuracy = 100 * mean(vec(mapslices(indmax, probs, 1)) .== labels .+ 1) println(mx.format("Accuracy on eval set: {1:.2f}%", accuracy)) # => Accuracy on eval set: 97.90% ``` <aside class="notes">推測も簡単っ(ゴリ押し)<br>もちろんここで Confusion Matrix を生成などして他の Metrics を評価してもOK</aside> ---- <!-- .slide: data-background="#872724" --> ## Web アプリに組み込んでみた ---- <!-- .slide: data-background="#872724" --> ### Julia Web 系ライブラリ + [HttpServer.jl](https://github.com/JuliaWeb/HttpServer.jl)(HttpServer 基本ライブラリ) + [Pages.jl](https://github.com/EricForgy/Pages.jl)(簡単 インタラクティブWeb F/W) + **[Mux.jl](https://github.com/JuliaWeb/Mux.jl)**(ベーシックな Webアプリ F/W) <aside class="notes">Pages.jl, Mux.jl ともに内部で HttpServer.jl を利用しています。<br>今回は <b>Mux</b> を利用っ</aside> ---- <!-- .slide: data-background="#872724" --> ### app.jl(抜粋)(1) ```julia= using Mux using MXNet import JSON model = mx.load_checkpoint("MXNET_CNN_20170625", 0, mx.FeedForward) ``` <aside class="notes"><code>mx.load_checkpoint()</code> は MXNet で学習済のモデルを読み込む記述っ</aside> ---- <!-- .slide: data-background="#872724" --> ### app.jl(抜粋)(2) ```ruby=23 function classify(a::Vector{Float32}) image = reshape(a, (28, 28, 1, 1)) result = mx.predict(model, mx.ArrayDataProvider(image)) return vec(result) end function classify(a::Vector) classify(convert(Vector{Float32}, a)) end ``` <aside class="notes">先ほど関数は <code>f(x) = 〜</code> のように1行で定義しましたが、<code>function</code> キーワードを使って複数行の関数も定義できますっ<br><code>return</code>を明示しない場合、最後の式の結果が戻り値になりますっ<br>引数の後の <code>::Xxxx</code> は、引数の型アノテーション、これを明示することで同じ名前で関数が多重定義でき、実行時に適切なものが呼ばれます(多重ディスパッチと言います)っ</aside> ---- <!-- .slide: data-background="#872724" --> ### app.jl(抜粋)(3) ```ruby=35 function classify(req::Dict) params = parseQuery(req) return try JSON.json(classify(JSON.parse(params[:x]))) catch JSON.json(zeros(Float32, 10)) end end ``` <aside class="notes">これも多重定義、引数は Mux アプリに渡ってくる <code>req</code> 辞書(HttpRequest の内容を辞書に変換したもの)っ</aside> ---- <!-- .slide: data-background="#872724" --> ### app.jl(抜粋)(4) ```python=44 @app sv = ( Mux.defaults, page(req->Mux.fresp("classify.html")), branch(req->req[:method]=="POST"&&length(req[:path])==1&&Mux.matchpath!(["classify"], req), classify), Mux.notfound()) serve(sv) ``` <aside class="notes">Webアプリの定義っ<br>パス<code>/</code>でアクセスしたら classify.html の内容を表示し、Post で <code>/classify</code> にアクセスしたら <code>classify()</code> 関数を呼んで処理した結果をresponseっ<br>あ、あと<code>○->〜</code>は無名関数(ラムダ式)っ</aside> ---- <!-- .slide: data-background="#872724" --> ### HTML(+JavaScript)(抜粋) ```htmlmixed=15 <script> // (ry function classify() { var myCanvas = document.getElementById("myCanvas"); var ctx = myCanvas.getContext("2d"); var data = []; // (ry: canvas からピクセルデータを読み込む処理 jQuery.ajax("classify", { dataType: "json", data: "x=" + JSON.stringify(data), type: "POST", success: function (res) { // (ry: 整形して表示する処理 } }); } // (ry </script> ``` <!-- .element: style="font-size:40%" --> ---- <!-- .slide: data-background="#872724" --> ```htmlmixed=138 <div id="board"> <canvas id="myCanvas" width="112px" height="112px"></canvas> <p> <button id="classify" onclick="classify()">Classify</button> <button id="clear" onclick="myClear()">Clear</button> </p><p> Result: <input type="text" id="result_output" size="5" value=""> <br><textarea id="result_detail" cols="30" rows="10"></textarea> </p> </div> ``` <!-- .element: style="font-size:40%" --> <aside class="notes">idとか関数名とかが<code>myXxxx</code>になっていて、いかにもサンプルっぽいですよね!(名前付けをさぼっただけ…)</aside> ---- <!-- .slide: data-background="#872724" --> ### 結果 ![五->5](https://i.imgur.com/26gzsUD.png)<!-- .element: style="width:40%" --> <aside class="notes">良い感じっ</aside> --- <!-- .slide: data-background="#27641e" --> + :white_check_mark: デモ + :white_check_mark: 自己紹介 + :white_check_mark: Julia とは? + :white_check_mark: Julia の高速性 + :white_check_mark: Julia で機械学習 --- <!-- .slide: data-background="#27641e" --> # まとめ ---- <!-- .slide: data-background="#27641e" --> + Julia 良いよ + 使ってみて良さを体感して欲しい + 退屈なことは Julia にやらせよう <aside class="notes">良さを伝えきれないっ<br>例えば今回は数値計算(科学技術計算)並行・並列処理の話をしていないけれど、気になる方はぜひ自分で調べて使ってみて欲しいですっ</aside> ---- <!-- .slide: data-background="#27641e" --> ## 情報収集 + [Google 検索](https://www.google.co.jp/search?q=julialang)(ググるときは `julialang` で!) + [Twitter #julialang](https://twitter.com/search?f=tweets&vertical=default&q=%23julialang)(公式ハッシュタグ) + [Qiita タグ Julia](http://qiita.com/tags/Julia "Juliaに関する投稿 - Qiita")(正式タグ) + [Mastodon 検索](http://realtime.userlocal.jp/toots/index?q=%23julialang "「#julialang」のリアルタイム検索 - マストドンリアルタイム検索")(積極的に情報発信!) <aside class="notes">実際に使ってみた方が情報発信してくれてたりします!<br>どう使われているか探してみようっ>どう使われているか探してみようっ</aside> --- <!-- .slide: data-background="#27641e" --> ご清聴ありがとうございます。

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully