SlideShare a Scribd company logo
Python
(2018-02-27)
Masahiro Sakai ( )
PYTHON
• Twitter: @masahiro_sakai
github: https://github.com/msakai/
G+: https://plus.google.com/+MasahiroSakai
• :
( )
• :
– ( Haskell)
–
–
•
• Python
• Python
•
……
• Haskell
– Haskell ( )
• Ruby
–
( Python )
– Ruby-GNOME2
• Python
– Chainer + α
– PyPI
DISCLAIMER
•
Python
–
–
–
• Python
–
•
•
•
•
関数プログラマから見たPythonと機械学習
•
– R MATLAB
•
– numpy/scipy, pandas, scikit-learn, matplotlib, Jupyter
Notebook,
–
Python
• ……
Python
• ) numpy.array ==
– numpy …
– Python
⇒
– sorted([np.zeros(2), np.zeros(2)])
• ( collections-extended
RangeMap )
: ……
• ……
•
……
• ) pandas itertuples
type(next(pd.DataFrame({"x" + str(i): [i] for i in range(253)}).itertuples()))
#=> pandas.core.frame.Pandas
type(next(pd.DataFrame({"x" + str(i): [i] for i in range(254)}).itertuples()))
#=> tuple
関数プログラマから見たPythonと機械学習
: Lisp-1
•
– Scheme, JavaScript
– Common Lisp, Ruby Lisp-2 ( )
•
Python Ruby
obj.foo(args) obj.foo(args)
( ) obj.foo() obj.foo(), obj.foo
obj.foo obj.method(:foo)
m(args) m.call(args), m[args]
: Lisp-1
• ……
→
→
• Ruby Lisp-2
•
•
Python Ruby
obj.foo(…) obj.foo(…), obj.foo …
( ) obj.foo() obj.foo(), obj.foo
obj.foo obj.method(:foo)
m(…) m.call(…), m[…]
• (PEP 484)
• mypy
def greeting(name: str) -> str:
return 'Hello ' + name
print(greeting(0))
# => error: Argument 1 to "greeting" has incompatible
type "int"; expected "str"
• Haskeller
–
–
•
– →
• Python Haskell
–
• List Tuple List
……
• (gradual typing)
– (dynamic typing) (static typing)
– Jeremy G. Siek and Walid Taha, Gradual Typing for Functional Languages, in
Proceedings of the 2006 Scheme and Functional Programming Workshop
•
– dynamic type: Any … Any
– type consistency relation: A B
• A = B Any
( : int→Any Any→str)
–
int ⊑ Any ⊑ str
•
(1)
(2)
•
– Python (mypy), TypeScript, Closure, Hack, Flow, C#?
–
• Python
–
• Python (mypy)
• ……
– (Any )
• e.g. Blame Calculus ( )
• Python (mypy)
• :
• (np.array, chainer.Variable )
⇒
• shape
– shape
•
( : forward backward )
(1)
def __call__(self, x : np.array) -> np.array:
• shape Array(m,n,o)
……
– reshape
⇒ (c.f. )
– Haskell hmatrix API †
……
•
(2)
† https://hackage.haskell.org/package/hmatrix-0.18.2.0/docs/Numeric-LinearAlgebra-Static.html
: Chainer
• Chainer
DSL
–
–
type_check.expect(in_types[0].shape == in_types[1].shape)
Expect: in_types[0].shape == in_types[1].shape
Actual: (3,) != (2,)
http://blog.unnono.net/2015/10/chainer-typecheck.html
(3)
•
•
…
•
関数プログラマから見たPythonと機械学習
• CPython
• GPU CPU
– Python
……
– NN CPU
– GPU
……
numpy
• numpy
• numpy
( numpy )
– : x[np.arange(x.shape[0])[:, None], p]
–
•
•
( 1 540 2.1GB )
parsy-1.1.0 290m7.032s
pyparsing-2.2.0 562m41.623s
funcparserlib-0.3.6 79m45.315s
megaparsec-5.3.1 (Haskell) 18m12.025s
attoparsec-0.13.1.0 (Haskell) 15m46.415s
: Python str Haskell
ByteString(bytes )
• :
–
–
……
• Cython
–
–
•
–
CPython
(Go )
• GIL (Global Interpreter Lock)
–
CPython
……
ONNX-Chainer ……
関数プログラマから見たPythonと機械学習
• Python
• Python
–
– Python
•

More Related Content

PDF
SIGNATE 産業技術総合研究所 衛星画像分析コンテスト 2位入賞モデルの工夫点
PDF
証明プログラミング超入門
PPTX
AVX-512(フォーマット)詳解
PDF
組み込み関数(intrinsic)によるSIMD入門
PPTX
論文の図表レイアウト例
PDF
合成変量とアンサンブル:回帰森と加法モデルの要点
PDF
プログラムを高速化する話Ⅱ 〜GPGPU編〜
SIGNATE 産業技術総合研究所 衛星画像分析コンテスト 2位入賞モデルの工夫点
証明プログラミング超入門
AVX-512(フォーマット)詳解
組み込み関数(intrinsic)によるSIMD入門
論文の図表レイアウト例
合成変量とアンサンブル:回帰森と加法モデルの要点
プログラムを高速化する話Ⅱ 〜GPGPU編〜

What's hot (20)

PPTX
Deep Learningのための専用プロセッサ「MN-Core」の開発と活用(2022/10/19東大大学院「 融合情報学特別講義Ⅲ」)
PDF
KCFの紹介
PDF
最適化超入門
PDF
グラフデータ分析 入門編
PDF
ICLR2019 読み会in京都 ICLRから読み取るFeature Disentangleの研究動向
PDF
3種類のTEE比較(Intel SGX, ARM TrustZone, RISC-V Keystone)
PDF
ブラックボックス最適化とその応用
PDF
CPU / GPU高速化セミナー!性能モデルの理論と実践:実践編
PDF
相互相関関数の最大化と時間差推定
PDF
ソフト高速化の専門家が教える!AI・IoTエッジデバイスの選び方
PDF
5分で分かるアジャイルムーブメントの歴史 拡大版
PDF
DSIRNLP#1 ランキング学習ことはじめ
PDF
2値化CNN on FPGAでGPUとガチンコバトル(公開版)
PDF
ZytleBot: ROSベースの自律移動ロボットへのFPGAの統合に向けて
PPTX
Pycairo を使ってみる その1
PPTX
CPU / GPU高速化セミナー!性能モデルの理論と実践:理論編
PDF
Active Learning 入門
PDF
AndroidアプリのKotlin移行時に遭遇した問題と対処例
PDF
12 分くらいで知るLuaVM
PDF
MLflowによる機械学習モデルのライフサイクルの管理
Deep Learningのための専用プロセッサ「MN-Core」の開発と活用(2022/10/19東大大学院「 融合情報学特別講義Ⅲ」)
KCFの紹介
最適化超入門
グラフデータ分析 入門編
ICLR2019 読み会in京都 ICLRから読み取るFeature Disentangleの研究動向
3種類のTEE比較(Intel SGX, ARM TrustZone, RISC-V Keystone)
ブラックボックス最適化とその応用
CPU / GPU高速化セミナー!性能モデルの理論と実践:実践編
相互相関関数の最大化と時間差推定
ソフト高速化の専門家が教える!AI・IoTエッジデバイスの選び方
5分で分かるアジャイルムーブメントの歴史 拡大版
DSIRNLP#1 ランキング学習ことはじめ
2値化CNN on FPGAでGPUとガチンコバトル(公開版)
ZytleBot: ROSベースの自律移動ロボットへのFPGAの統合に向けて
Pycairo を使ってみる その1
CPU / GPU高速化セミナー!性能モデルの理論と実践:理論編
Active Learning 入門
AndroidアプリのKotlin移行時に遭遇した問題と対処例
12 分くらいで知るLuaVM
MLflowによる機械学習モデルのライフサイクルの管理
Ad

Similar to 関数プログラマから見たPythonと機械学習 (20)

PPTX
SociaLite: High-level Query Language for Big Data Analysis
PDF
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
PDF
Migrating from matlab to python
KEY
PDF
Swift for tensorflow
PDF
Real Time Big Data Management
PPTX
Introduction to Haskell: 2011-04-13
PDF
Numba: Array-oriented Python Compiler for NumPy
PPTX
Yin Yangs of Software Development
PDF
Python高级编程(二)
PDF
Learning notes of r for python programmer (Temp1)
PDF
Natural Language Processing with CNTK and Apache Spark with Ali Zaidi
PPTX
Functional Programming, simplified
PDF
チームメイトのためにdocstringを書こう! pyconjp2019
PDF
Hands on lua
PDF
Foilsを使ってみた。
PDF
01. haskell introduction
PDF
Hadoop Overview kdd2011
PDF
Rug hogan-10-03-2012
KEY
SacalaZa #1
SociaLite: High-level Query Language for Big Data Analysis
[Let'Swift 2019] 실용적인 함수형 프로그래밍 워크샵
Migrating from matlab to python
Swift for tensorflow
Real Time Big Data Management
Introduction to Haskell: 2011-04-13
Numba: Array-oriented Python Compiler for NumPy
Yin Yangs of Software Development
Python高级编程(二)
Learning notes of r for python programmer (Temp1)
Natural Language Processing with CNTK and Apache Spark with Ali Zaidi
Functional Programming, simplified
チームメイトのためにdocstringを書こう! pyconjp2019
Hands on lua
Foilsを使ってみた。
01. haskell introduction
Hadoop Overview kdd2011
Rug hogan-10-03-2012
SacalaZa #1
Ad

More from Masahiro Sakai (20)

PDF
DeepXplore: Automated Whitebox Testing of Deep Learning
PDF
Towards formal verification of neural networks
PDF
Writing a SAT solver as a hobby project
PDF
RClassify: Classifying Race Conditions in Web Applications via Deterministic ...
PDF
ゼロピッチ: MOOC
PDF
SAT/SMT solving in Haskell
PDF
SAT/SMTソルバの仕組み
PDF
Introduction to Max-SAT and Max-SAT Evaluation
PDF
Aluminum: Principled Scenario Exploration through Minimality
PDF
代数的実数とCADの実装紹介
KEY
How a CDCL SAT solver works
PDF
Omega test and beyond
PDF
萩野服部研究室 スキー合宿 2012 自己紹介(酒井)
PDF
自動定理証明の紹介
PDF
“Adoption and Focus: Practical Linear Types for Imperative Programming”他の紹介@P...
PDF
“Design and Implementation of Generics for the .NET Common Language Runtime”他...
PDF
Relaxed Dependency Analysis
PDF
“Symbolic bounds analysis of pointers, array indices, and accessed memory reg...
PDF
自然言語をラムダ式で解釈する体系PTQのHaskell実装
PDF
Whole Program Paths 等の紹介@PLDIr#3
DeepXplore: Automated Whitebox Testing of Deep Learning
Towards formal verification of neural networks
Writing a SAT solver as a hobby project
RClassify: Classifying Race Conditions in Web Applications via Deterministic ...
ゼロピッチ: MOOC
SAT/SMT solving in Haskell
SAT/SMTソルバの仕組み
Introduction to Max-SAT and Max-SAT Evaluation
Aluminum: Principled Scenario Exploration through Minimality
代数的実数とCADの実装紹介
How a CDCL SAT solver works
Omega test and beyond
萩野服部研究室 スキー合宿 2012 自己紹介(酒井)
自動定理証明の紹介
“Adoption and Focus: Practical Linear Types for Imperative Programming”他の紹介@P...
“Design and Implementation of Generics for the .NET Common Language Runtime”他...
Relaxed Dependency Analysis
“Symbolic bounds analysis of pointers, array indices, and accessed memory reg...
自然言語をラムダ式で解釈する体系PTQのHaskell実装
Whole Program Paths 等の紹介@PLDIr#3

Recently uploaded (20)

PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
OOP with Java - Java Introduction (Basics)
PPTX
additive manufacturing of ss316l using mig welding
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PDF
Digital Logic Computer Design lecture notes
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PPTX
Geodesy 1.pptx...............................................
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
web development for engineering and engineering
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Welding lecture in detail for understanding
PPT
Project quality management in manufacturing
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
Well-logging-methods_new................
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPT
Mechanical Engineering MATERIALS Selection
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
R24 SURVEYING LAB MANUAL for civil enggi
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
OOP with Java - Java Introduction (Basics)
additive manufacturing of ss316l using mig welding
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Digital Logic Computer Design lecture notes
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
Geodesy 1.pptx...............................................
Operating System & Kernel Study Guide-1 - converted.pdf
web development for engineering and engineering
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Welding lecture in detail for understanding
Project quality management in manufacturing
Automation-in-Manufacturing-Chapter-Introduction.pdf
Well-logging-methods_new................
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
Mechanical Engineering MATERIALS Selection
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
bas. eng. economics group 4 presentation 1.pptx

関数プログラマから見たPythonと機械学習