tfp.sts
( )
Yuta Kashino ( )
❖ BakFoo, Inc. CEO
❖
❖ Kubernetes /
❖ POC / →
❖
❖ k8s, Web ,
❖ Zope 3 / Python 2.1
❖ Zope Japan
❖ Yahoo! Japan
❖ (~20 )
❖
❖ @yutakashino
❖ tfp
❖
❖
❖ VI/MCMC
❖ CO2
tfp.sts
❖ Structural Time Series
❖
❖
❖
❖
❖
|
t-2
|
t-1
|
t
|
t+1
|
t+2
❖
❖
X0
P0
Xk-1
Pk-1
Xk
p = A Xk-1 + B uk + wk
Pk
p = A Pk-1 AT + Qk
Yk = C Xk + zk
K = Pk
p H / (H Pk
p HT + R)
Xk = Xk
p + K (Yk - Hkp )
Xk
Pk = ( I - KH ) Pk
p
Xk
Pk
|
k-1
|
k
k -> k-1
( )
uk :
wk :
Qk :
Yk :
zk :
K :
R :
X :
P :
G(X, P)
❖ Michel van Biezen (Raytheon)
❖ https://www.youtube.com/playlist?list=PLX2gX-
ftPVXU3oUFNATxGXY90AULiqnWT
❖ 27
(STS)
❖ Structual Time Series Model
❖
❖
❖ : ( )
|
t-2
|
t-1
|
t
|
t+1
|
t+2
TFP VI: tfp.vi
❖ sts model
❖ sts.LocalLinearTrend
❖ sts.Sum([trend, seasonal]…)
❖ sts.build_factored_surrogate_posterier
❖ arg: model
❖ vi.fit_surrogate_porterier
❖ arg: model
❖ arg: surrogate_posterier
❖ arg: num_step
❖ sts.forecast
sts model
❖ sts.LocalLinearTrend
❖ sts.Sum([trend, seasonal]…)
sts.LocalLinearTrend
❖ level, scope
LocalLinearTrend
StructuralTimeSeries
LocalLenearTrendSpaceSteteModel
LinearGaussianStateSpaceModel
tfd.LinearGaussianStateSpaceModel
❖
❖ https://www.tensorflow.org/probability/api_docs/python/tfp/
distributions/LinearGaussianStateSpaceModel?hl=ja
sts.Sum([trend, seasonal]…)
❖ sts model
|
t-1
|
t
|
t+1
sts.build_factored_surrogate_posterier
❖ sts.build_factored_surrogate_posterier
❖ return: variational_posterior
(tfd.JointDistributionNamed)
❖ ↑
❖ q
•- data hypothesis( )
- :
-
-
P(H | D) =
P(H)P(D | H)
P
H P(H)P(D|H)
P(x) =
X
y
P(x, y)
P(x, y) = P(x)P(y | x)
posterior likelihoodprior
evidence
- :
- :
-
-
- :
P(H | D) =
P(H)P(D | H)
P
H P(H)P(D|H)
likelihood priorposterior
P(✓ | D, m) =
P(D | ✓, m)P(✓ | m)
P(D | m)
m:
P(x | D, m) =
Z
P(x | ✓, D, m)P(✓ | D, m)d✓
P(m | D) =
P(D | m)P(m)
P(D)
evidence
✓ ⇠ Beta(✓ | 2, 2)
- (MCMC)
- (Variational Inference)
P(✓ | D, m) =
P(D | ✓, m)P(✓ | m)
P(D | m) Z
P(D | ✓, m)P(✓)d✓
evidence
P(θ|D,m) KL q(θ)
ELBO
⇤
= argmin KL(q(✓; ) || p(✓ | D))
= argmin Eq(✓; )[logq(✓; ) p(✓ | D)]
ELBO( ) = Eq(✓; )[p(✓, D) logq(✓; )]
⇤
= argmax ELBO( )
P(✓ | D, m) =
P(D | ✓, m)P(✓ | m)
P(D | m)
- KL =ELBO
- P q
q(✓; 1)
q(✓; 5)
p(✓, D) p(✓, D)
✓✓
⇤
= argmax ELBO( )
ELBO( ) = Eq(✓; )[p(✓, D) logq(✓; )]
- P q
- :
- ADVI: Automatic Differentiation Variational Inference
- BBVI: Blackbox Variational Inference
arxiv:1603.00788
arxiv:1401.0118
https://github.com/HIPS/autograd/blob/master/examples/bayesian_neural_net.py
- VI
-
- David MacKay “Lecture 14 of the Cambridge Course”
- PRML 10
http://www.inference.org.uk/itprnn_lectures/
sts.build_factored_surrogate_posterier
❖ sts.build_factored_surrogate_posterier
❖ return: variational_posterior
(tfd.JointDistributionNamed)
❖ q
q(✓; 1)
q(✓; 5)
p(✓, D) p(✓, D)
✓✓
ELBO
❖ vi.fit_surrogate_porterier
⇤
= argmax ELBO( )
ELBO( ) = Eq(✓; )[p(✓, D) logq(✓; )]
vi.fit_surrogate_posterier
❖ vi.fit_surrogate_porterier
❖ model
❖ surrogate_posterier
❖ num_step
sts.forecast
❖ sts.forecast
❖
TFP MCMC: sts.fit_with_hmc
❖ sts model
❖ sts.Sum([trend, seasonal]…)
❖ sts.fit_with_hmc
❖ model
❖ data
TFP MCMC: sts.fit_with_hmc
❖ CO2
❖ 70
❖ 10 90
❖ …
-
-
P(✓ | D, m) = P(D | ✓, m)P(✓ | m)
liklihood priorposterior
✓
https://github.com/dfm/corner.py
✓
http://twiecki.github.io/blog/2014/01/02/visualizing-mcmc/
NUTS (HMC)
Metropolis
-Hastings
時系列データと確率的プログラミング tfp.sts
tfp: normal
❖ tfp.python.distributions.normal
❖ https://github.com/tensorflow/probability/blob/v0.11.0/tensorflow_probability/
python/distributions/normal.py
❖ tf.random.normal
❖ https://www.tensorflow.org/api_docs/python/tf/random/normal
❖ tf.python.ops.random_ops
❖ https://github.com/tensorflow/tensorflow/blob/v2.3.0/tensorflow/python/ops/
random_ops.py#L43-L98
❖ tf.python.ops.distributions.distribution.py
❖ https://github.com/tensorflow/tensorflow/blob/v2.3.0/tensorflow/python/ops/
distributions/distribution.py
❖ tensorflow::ops::RandomNormal
❖ https://www.tensorflow.org/api_docs/cc/class/tensorflow/ops/random-normal
❖ https://github.com/tensorflow/tensorflow/blob/v2.3.0/tensorflow/core/ops/
random_ops.cc
❖ https://github.com/tensorflow/tensorflow/blob/v2.3.0/tensorflow/core/kernels/
parameterized_truncated_normal_op.cc
❖ https://github.com/tensorflow/tensorflow/blob/v2.3.0/tensorflow/core/kernels/
parameterized_truncated_normal_op.h
❖ Eigen::MatrixExponential
PyMC3: normal
❖ pymc3.distributions.continuous.normal
❖ https://github.com/pymc-devs/pymc3/blob/master/pymc3/
distributions/continuous.py
❖ scipy.stas.norm
❖ https://docs.scipy.org/doc/scipy/reference/generated/
scipy.stats.norm.html#scipy.stats.norm
❖ scipy.stats._continuous_distns.norm_gen
❖ https://github.com/scipy/scipy/blob/master/scipy/stats/
_continuous_distns.py
❖ np.exp
❖ https://numpy.org/doc/stable/reference/generated/numpy.exp.html
❖ np.core.src.npymath.npy_math_complex.c.src
❖ https://github.com/numpy/numpy/blob/master/numpy/core/src/
npymath/npy_math_complex.c.src#L196
tfp.sts: pros
❖ tfp.distributions (tfd)
❖ colaboratory
❖ @tf.function(experimental_compile=true)
❖ Bijector API
❖ API
❖ BigQuery
tfp.sts: cons
❖ MCMC …
❖
❖ Traceback
❖ API Tensor shape
❖ API
❖
❖ PyMC4, edword2 …
❖
FBProphet
❖ Python cmdstan
❖ stan
❖ https://github.com/facebook/prophet/blob/master/python/stan/unix/
prophet.stan
❖ Prophet
❖ https://github.com/facebook/prophet/blob/master/python/fbprophet/
forecaster.py
❖
❖ https://peerj.com/preprints/3190/
❖
❖ /
❖ Stan GAM
❖
❖ GAM
TFP TF
PPL
TFP
TensorFlow(TF) + (PPL)
TF:
PPL: + +
1. TF:
-
- :
1. TF:
1. TF:
-
-
- GPU / TPU
Inception v3 Inception v4
# of parameters: 42,679,816
# of layers: 48
1. TF:
- Keras, Slim
- TensorBoard
1. TF:
-
- tf .distributions
2.
x:
x⇤
s P(x | ↵)
✓⇤
⇠ Beta(✓ | 1, 1)
2.
- ( )
p(x, ✓) = Beta(✓ | 1, 1)
50Y
n=1
Bernoulli(xn | ✓),
2.
-
log_prob()
-
mean()
-
sample()
- tfp.distributions
3.
Edward TF
TFP
- TFP = TensorFlow +
+ +
- TensorFlow
-
- TF GPU, TPU, TensorBoard, Keras
-
- TensorFlow
Questions
kashino@bakfoo.com
@yutakashino
BakFoo, Inc.
NHK NMAPS:
+
BakFoo, Inc.
PyConJP 2015
Python
BakFoo, Inc.
BakFoo, Inc.
QUICK: Workstation, Qr1 | AI
BakFoo, Inc.
: SNS +

More Related Content

PDF
多様な強化学習の概念と課題認識
PPTX
劣モジュラ最適化と機械学習1章
PDF
Optuna Dashboardの紹介と設計解説 - 2022/12/10 Optuna Meetup #2
PPTX
Graph Neural Networks
PDF
グラフニューラルネットワークとグラフ組合せ問題
PPT
文献調査をどのように行うべきか?
PDF
[DL輪読会]Deep Learning 第15章 表現学習
PDF
競技プログラミングにおけるコードの書き方とその利便性
多様な強化学習の概念と課題認識
劣モジュラ最適化と機械学習1章
Optuna Dashboardの紹介と設計解説 - 2022/12/10 Optuna Meetup #2
Graph Neural Networks
グラフニューラルネットワークとグラフ組合せ問題
文献調査をどのように行うべきか?
[DL輪読会]Deep Learning 第15章 表現学習
競技プログラミングにおけるコードの書き方とその利便性

What's hot (20)

PDF
機械学習による統計的実験計画(ベイズ最適化を中心に)
PPTX
遺伝的アルゴリズム・遺伝的プログラミング
PDF
[DL輪読会]1次近似系MAMLとその理論的背景
PDF
はじめてのKrylov部分空間法
PDF
ブラックボックス最適化とその応用
PPTX
東京大学2020年度深層学習(Deep learning基礎講座) 第9回「深層学習と自然言語処理」
PDF
TensorFlow XLAは、 中で何をやっているのか?
PDF
20221226_TITECH_lecture_ishizaki_public.pdf
PDF
KDD Cup 2021 時系列異常検知コンペ 参加報告
PDF
グラフデータ分析 入門編
PDF
[DL輪読会]Relational inductive biases, deep learning, and graph networks
PDF
TensorFlowで逆強化学習
PDF
Rで学ぶ回帰分析と単位根検定
PDF
ゼロから始める深層強化学習(NLP2018講演資料)/ Introduction of Deep Reinforcement Learning
PPTX
多目的遺伝的アルゴリズム
PDF
相互相関関数の最大化と時間差推定
PPTX
【DL輪読会】Efficiently Modeling Long Sequences with Structured State Spaces
PDF
Control as Inference (強化学習とベイズ統計)
PDF
Deep Q-LearningでFXしてみた
PDF
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
機械学習による統計的実験計画(ベイズ最適化を中心に)
遺伝的アルゴリズム・遺伝的プログラミング
[DL輪読会]1次近似系MAMLとその理論的背景
はじめてのKrylov部分空間法
ブラックボックス最適化とその応用
東京大学2020年度深層学習(Deep learning基礎講座) 第9回「深層学習と自然言語処理」
TensorFlow XLAは、 中で何をやっているのか?
20221226_TITECH_lecture_ishizaki_public.pdf
KDD Cup 2021 時系列異常検知コンペ 参加報告
グラフデータ分析 入門編
[DL輪読会]Relational inductive biases, deep learning, and graph networks
TensorFlowで逆強化学習
Rで学ぶ回帰分析と単位根検定
ゼロから始める深層強化学習(NLP2018講演資料)/ Introduction of Deep Reinforcement Learning
多目的遺伝的アルゴリズム
相互相関関数の最大化と時間差推定
【DL輪読会】Efficiently Modeling Long Sequences with Structured State Spaces
Control as Inference (強化学習とベイズ統計)
Deep Q-LearningでFXしてみた
数学カフェ 確率・統計・機械学習回 「速習 確率・統計」
Ad

Similar to 時系列データと確率的プログラミング tfp.sts (8)

PDF
深層学習とベイズ統計
PDF
ベイジアンディープニューラルネット
PDF
Pycon2017
DOCX
LSTM Framework For Univariate Time series
PDF
R Interface for TensorFlow
PDF
Deep Learning in Finance
PDF
The TensorFlow dance craze
PDF
Introduction to modern Variational Inference.
深層学習とベイズ統計
ベイジアンディープニューラルネット
Pycon2017
LSTM Framework For Univariate Time series
R Interface for TensorFlow
Deep Learning in Finance
The TensorFlow dance craze
Introduction to modern Variational Inference.
Ad

More from Yuta Kashino (20)

PDF
Python kansai2019
PDF
Mlse20190208
PDF
Ml15m2018 10-27
PDF
Pydata2017 11-29
PDF
私は如何にして心配するのを止めてPyTorchを愛するようになったか
PDF
Wasserstein GAN Tfug2017 07-12
PDF
確率的プログラミングライブラリEdward
PDF
PyConJP2016: 週末サイエンティストのススメ
PDF
機械学習ビジネス研究会 第01回
PDF
深層学習ライブラリの環境問題Chainer Meetup2016 07-02
PDF
Chainer meetup2016 03-19pub
PDF
"Automatic Variational Inference in Stan" NIPS2015_yomi2016-01-20
PDF
深層学習ライブラリのプログラミングモデル
PDF
TensorFlow White Paperを読む
PDF
Deep learning Libs @twm
PDF
日本のオープンデータプラットフォームをPythonでつくる
PDF
Gunosy2015 09-16ts
PDF
Gunosy2015-08-05
PDF
Gunosy2015 07-07
PDF
Gunosy2015-06-03
Python kansai2019
Mlse20190208
Ml15m2018 10-27
Pydata2017 11-29
私は如何にして心配するのを止めてPyTorchを愛するようになったか
Wasserstein GAN Tfug2017 07-12
確率的プログラミングライブラリEdward
PyConJP2016: 週末サイエンティストのススメ
機械学習ビジネス研究会 第01回
深層学習ライブラリの環境問題Chainer Meetup2016 07-02
Chainer meetup2016 03-19pub
"Automatic Variational Inference in Stan" NIPS2015_yomi2016-01-20
深層学習ライブラリのプログラミングモデル
TensorFlow White Paperを読む
Deep learning Libs @twm
日本のオープンデータプラットフォームをPythonでつくる
Gunosy2015 09-16ts
Gunosy2015-08-05
Gunosy2015 07-07
Gunosy2015-06-03

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles – August ’25 Week III
PDF
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
PPT
Module 1.ppt Iot fundamentals and Architecture
DOCX
search engine optimization ppt fir known well about this
PDF
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
PDF
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
PDF
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
PDF
A comparative study of natural language inference in Swahili using monolingua...
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
A contest of sentiment analysis: k-nearest neighbor versus neural network
PDF
Enhancing emotion recognition model for a student engagement use case through...
PDF
DP Operators-handbook-extract for the Mautical Institute
PDF
STKI Israel Market Study 2025 version august
PPTX
Tartificialntelligence_presentation.pptx
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
O2C Customer Invoices to Receipt V15A.pptx
PDF
A review of recent deep learning applications in wood surface defect identifi...
PPT
Geologic Time for studying geology for geologist
PPT
What is a Computer? Input Devices /output devices
NewMind AI Weekly Chronicles – August ’25 Week III
Hybrid horned lizard optimization algorithm-aquila optimizer for DC motor
Module 1.ppt Iot fundamentals and Architecture
search engine optimization ppt fir known well about this
TrustArc Webinar - Click, Consent, Trust: Winning the Privacy Game
DASA ADMISSION 2024_FirstRound_FirstRank_LastRank.pdf
How ambidextrous entrepreneurial leaders react to the artificial intelligence...
A comparative study of natural language inference in Swahili using monolingua...
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
A contest of sentiment analysis: k-nearest neighbor versus neural network
Enhancing emotion recognition model for a student engagement use case through...
DP Operators-handbook-extract for the Mautical Institute
STKI Israel Market Study 2025 version august
Tartificialntelligence_presentation.pptx
sustainability-14-14877-v2.pddhzftheheeeee
Assigned Numbers - 2025 - Bluetooth® Document
O2C Customer Invoices to Receipt V15A.pptx
A review of recent deep learning applications in wood surface defect identifi...
Geologic Time for studying geology for geologist
What is a Computer? Input Devices /output devices

時系列データと確率的プログラミング tfp.sts