mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-14 14:32:37 +02:00
Pre-devel-move check in
This commit is contained in:
parent
643f338337
commit
5405dbd1bc
3 changed files with 32 additions and 25 deletions
|
|
@ -107,14 +107,14 @@ class Symbolic_core():
|
|||
|
||||
# Do symbolic work to compute derivatives.
|
||||
for key, func in self.expressions.items():
|
||||
if func['function'].is_Matrix:
|
||||
rows = func['function'].shape[0]
|
||||
cols = func['function'].shape[1]
|
||||
self.expressions[key]['derivative'] = sym.zeros(rows, cols)
|
||||
for i in xrange(rows):
|
||||
for j in xrange(cols):
|
||||
self.expressions[key]['derivative'][i, j] = extract_derivative(func['function'][i, j], derivative_arguments)
|
||||
else:
|
||||
# if func['function'].is_Matrix:
|
||||
# rows = func['function'].shape[0]
|
||||
# cols = func['function'].shape[1]
|
||||
# self.expressions[key]['derivative'] = sym.zeros(rows, cols)
|
||||
# for i in xrange(rows):
|
||||
# for j in xrange(cols):
|
||||
# self.expressions[key]['derivative'][i, j] = extract_derivative(func['function'][i, j], derivative_arguments)
|
||||
# else:
|
||||
self.expressions[key]['derivative'] = extract_derivative(func['function'], derivative_arguments)
|
||||
|
||||
def _set_parameters(self, parameters):
|
||||
|
|
|
|||
|
|
@ -6,18 +6,18 @@ from poisson import Poisson
|
|||
from student_t import StudentT
|
||||
from likelihood import Likelihood
|
||||
from mixed_noise import MixedNoise
|
||||
# TODO need to fix this in a config file.
|
||||
# TODO need to add the files to the git repo!
|
||||
#try:
|
||||
#import sympy as sym
|
||||
#sympy_available=True
|
||||
#except ImportError:
|
||||
#sympy_available=False
|
||||
#if sympy_available:
|
||||
## These are likelihoods that rely on symbolic.
|
||||
#from symbolic import Symbolic
|
||||
#from sstudent_t import SstudentT
|
||||
#from negative_binomial import Negative_binomial
|
||||
##from skew_normal import Skew_normal
|
||||
#from skew_exponential import Skew_exponential
|
||||
#from null_category import Null_category
|
||||
#TODO need to fix this in a config file.
|
||||
#TODO need to add the files to the git repo!
|
||||
try:
|
||||
import sympy as sym
|
||||
sympy_available=True
|
||||
except ImportError:
|
||||
sympy_available=False
|
||||
if sympy_available:
|
||||
#These are likelihoods that rely on symbolic.
|
||||
from symbolic import Symbolic
|
||||
from sstudent_t import SstudentT
|
||||
from negative_binomial import Negative_binomial
|
||||
from skew_normal import Skew_normal
|
||||
from skew_exponential import Skew_exponential
|
||||
# from null_category import Null_category
|
||||
|
|
|
|||
|
|
@ -2,15 +2,22 @@ import sys
|
|||
import numpy as np
|
||||
import sympy as sym
|
||||
from sympy import Function, S, oo, I, cos, sin, asin, log, erf, pi, exp, sqrt, sign, gamma, polygamma
|
||||
|
||||
from sympy.matrices import Matrix
|
||||
########################################
|
||||
## Try to do some matrix functions: problem, you can't do derivatives
|
||||
## with respect to matrix functions :-(
|
||||
|
||||
class GPySymMatrix(Matrix):
|
||||
def __init__(self, indices):
|
||||
Matrix.__init__(self)
|
||||
def atoms(self):
|
||||
return [e2 for e in self for e2 in e.atoms()]
|
||||
|
||||
class selector(Function):
|
||||
"""A function that returns an element of a Matrix depending on input indices."""
|
||||
nargs = 3
|
||||
|
||||
def fdiff(self, argindex=1):
|
||||
return selector(*self.args)
|
||||
@classmethod
|
||||
def eval(cls, X, i, j):
|
||||
if i.is_Number and j.is_Number:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue