Skip to content

Instantly share code, notes, and snippets.

View juancamilog's full-sized avatar

Juan Camilo Gamboa Higuera juancamilog

View GitHub Profile
@juancamilog
juancamilog / jacobian_segfault.py
Last active August 29, 2015 14:20
T.jacobian segfault
import numpy as np
import theano
import theano.tensor as T
from theano.compile import function
from theano.tensor.nlinalg import matrix_inverse
from theano.tensor.slinalg import solve
from theano.tensor.nlinalg import det
from theano.tensor.slinalg import cholesky
from theano.ifelse import ifelse
from theano.gradient import verify_grad
@juancamilog
juancamilog / gist:07fb1f72f5bb14916506
Last active August 29, 2015 14:20
output of jacobian_segfault.py
juancamilog@juancamilog:~/workspace/antoinette$ gdb python jacobian_segfault.py
GNU gdb (Ubuntu 7.7.1-0ubuntu5~14.04.2) 7.7.1
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
import numpy as np
import theano
import theano.tensor as T
from theano import function as F, shared as S
from theano.sandbox.linalg import psd
from theano.tensor.nlinalg import matrix_inverse,det
from time import time
if __name__=='__main__':
import theano
import theano.tensor as T
from theano.sandbox.linalg import psd,matrix_inverse,det,cholesky
import numpy as np
from time import time
def SEard(loghyp,X):
''' Squared exponential kernel with diagonal scaling matrix (one lengthscale per dimension)'''
N,idims = X.shape
import theano
import theano.tensor as T
from theano.sandbox.linalg import psd,matrix_inverse,det,cholesky
import numpy as np
from time import time
def SEard(loghyp,X):
''' Squared exponential kernel with diagonal scaling matrix (one lengthscale per dimension)'''
N,idims = X.shape
import theano
import theano.tensor as T
from theano.sandbox.linalg import psd,matrix_inverse,det,cholesky
import numpy as np
from time import time
def SEard(loghyp,X):
''' Squared exponential kernel with diagonal scaling matrix (one lengthscale per dimension)'''
N,idims = X.shape
import theano
import theano.tensor as T
from theano.sandbox.linalg import psd,matrix_inverse,det,cholesky
from theano.tensor.slinalg import solve_lower_triangular
import numpy as np
from time import time
def SEard(loghyp,X):
''' Squared exponential kernel with diagonal scaling matrix (one lengthscale per dimension)'''
N,idims = X.shape
@register_stabilize
@local_optimizer([Dot, Dot22])
def inv_as_solve(node):
if not imported_scipy:
return False
if isinstance(node.op, (Dot, Dot22)):
l, r = node.inputs
if l.owner and l.owner.op == matrix_inverse:
if CHECK l.owner.inputs[0] is PSD HERE:
import theano
import numpy as np
# inti vars
s = theano.tensor.matrix('s')
y = theano.tensor.vector('y')
r = theano.tensor.slinalg.Solve()(s, y)
# jacobian using scan
dr1 = theano.tensor.jacobian(r.flatten(), s)
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.