Upgrade to Pro — share decks privately, control downloads, hide ads and more …

PythonライブラリをElixirで開発してみた

yujikawa
December 22, 2017

 PythonライブラリをElixirで開発してみた

PythonのnumpyをElixirで開発を行いました。

yujikawa

December 22, 2017
Tweet

More Decks by yujikawa

Other Decks in Technology

Transcript

  1. ࣗݾ঺հ w ໊લ w ઒্༞࢘ Ώ͔͡Θ  w ॴଐ w

    ΧϥϏφςΫϊϩδʔ w ৬छ w όοΫΤϯυΤϯδχΞ w 5XJUUFS w !ZVKJLBXB@QZ w ීஈͷ͓࢓ࣄ w 1ZUIPOΛ࢖ͬͨγεςϜ։ൃ w ͦͷ͏ͪ&MJYJSͷγεςϜ։ൃ΍ΔΑɾɾʁ w ϓϥΠϕʔτ w &MJYJSษڧதʢ̎Χ݄͙Β͍ʁʣ w 1Z'VLVPLBͷ؅ཧਓ΍͍ͬͯ·͢
  2. ͲΜͳײ͔͡ʁ ϕΫτϧΛ࡞Δ &MJYJS iex> x = Numexy.new([1,2,3]) %Array{array: [1, 2,

    3], shape: {3, nil}} 1ZUIPO In [1]: numpy.array([1,2,3])
  3. ͲΜͳײ͔͡ʁ ϕΫτϧͷ಺ੵ &MJYJS iex> x = Numexy.new([1,2,3]) %Array{array: [1, 2,

    3], shape: {3, nil}} iex> y = Numexy.new([1,2,3]) %Array{array: [1, 2, 3], shape: {3, nil}} iex> Numexy.dot(x, y) 14 1ZUIPO In[1]: numpy.dot(x, y)
  4. ͲΜͳײ͔͡ʁ ࿦ཧճ࿏ʢ903Λ࡞Δʣ ANDճ࿏ def lgAND(x1,x2) do x = Numexy.new([x1, x2])

    w = Numexy.new([0.5, 0.5]) b = -0.7 Numexy.mul(x, w) |> Numexy.sum |> Kernel.+(b) |> output end NANDճ࿏ def lgNAND(x1,x2) do x = Numexy.new([x1, x2]) w = Numexy.new([-0.5, -0.5]) b = 0.7 Numexy.mul(x, w) |> Numexy.sum |> Kernel.+(b) |> output end ORճ࿏ def lgOR(x1,x2) do x = Numexy.new([x1, x2]) w = Numexy.new([0.5, 0.5]) b = -0.2 Numexy.mul(x, w) |> Numexy.sum |> Kernel.+(b) |> output end
  5. ͲΜͳײ͔͡ʁ ࿦ཧճ࿏ʢ903Λ࡞Δʣ iex> lgXOR(0,0) 0 iex> lgXOR(1,0) 1 iex> lgXOR(0,1)

    1 iex> lgXOR(1,1) 0 ࣮ߦ݁Ռ XORճ࿏ def lgXOR(x1,x2) do lgAND(lgNAND(x1, x2), lgOR(x1, x2)) end