Created
September 11, 2012 17:45
-
-
Save mrocklin/3700186 to your computer and use it in GitHub Desktop.
The Kalman filter represented in Theano syntax
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import theano | |
import theano.sandbox.linalg as linalg | |
mu = theano.tensor.matrix('mu') | |
Sigma = theano.tensor.matrix('Sigma') | |
H = theano.tensor.matrix('H') | |
R = theano.tensor.matrix('R') | |
data = theano.tensor.matrix('data') | |
dot = theano.tensor.dot | |
A = dot(Sigma, H.T) | |
B = R + dot(H, dot(Sigma, H.T)) | |
new_mu = mu + dot(A, linalg.solve(B, dot(H, mu) - data)) | |
new_mu.name = "updated_mu" | |
new_Sigma = Sigma - dot(dot(A, linalg.solve(B, H)), Sigma) | |
new_Sigma.name = "updated_Sigma" | |
inputs = [mu, Sigma, H, R, data] | |
outputs = [new_mu, new_Sigma] | |
n = 2000 | |
input_shapes = {mu: (n, 1), | |
Sigma: (n, n), | |
H: (n, n), | |
R: (n, n), | |
data: (n, 1)} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment