mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-18 13:55:14 +02:00
Import fix for Py3
This commit is contained in:
parent
6554c32d23
commit
786feded41
2 changed files with 45 additions and 44 deletions
|
|
@ -61,15 +61,15 @@ class InferenceMethodList(LatentFunctionInference, list):
|
||||||
for inf in state:
|
for inf in state:
|
||||||
self.append(inf)
|
self.append(inf)
|
||||||
|
|
||||||
from exact_gaussian_inference import ExactGaussianInference
|
from .exact_gaussian_inference import ExactGaussianInference
|
||||||
from laplace import Laplace
|
from .laplace import Laplace
|
||||||
from GPy.inference.latent_function_inference.var_dtc import VarDTC
|
from GPy.inference.latent_function_inference.var_dtc import VarDTC
|
||||||
from expectation_propagation import EP
|
from .expectation_propagation import EP
|
||||||
from expectation_propagation_dtc import EPDTC
|
from .expectation_propagation_dtc import EPDTC
|
||||||
from dtc import DTC
|
from .dtc import DTC
|
||||||
from fitc import FITC
|
from .fitc import FITC
|
||||||
from var_dtc_parallel import VarDTC_minibatch
|
from .var_dtc_parallel import VarDTC_minibatch
|
||||||
from svgp import SVGP
|
from .svgp import SVGP
|
||||||
|
|
||||||
# class FullLatentFunctionData(object):
|
# class FullLatentFunctionData(object):
|
||||||
#
|
#
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
# Licensed under the BSD 3-clause license (see LICENSE.txt)
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
from scipy import weave
|
#from scipy import weave
|
||||||
|
|
||||||
def std_norm_pdf(x):
|
def std_norm_pdf(x):
|
||||||
"""Standard Gaussian density function"""
|
"""Standard Gaussian density function"""
|
||||||
|
|
@ -37,41 +37,42 @@ def std_norm_cdf(x):
|
||||||
cdf_x = cdf_x.reshape(x_shape)
|
cdf_x = cdf_x.reshape(x_shape)
|
||||||
return cdf_x
|
return cdf_x
|
||||||
|
|
||||||
def std_norm_cdf_weave(x):
|
#Commented out since this isn't used...and since it breaks Py3 compatibility
|
||||||
"""
|
#def std_norm_cdf_weave(x):
|
||||||
Cumulative standard Gaussian distribution
|
# """
|
||||||
Based on Abramowitz, M. and Stegun, I. (1970)
|
# Cumulative standard Gaussian distribution
|
||||||
|
# Based on Abramowitz, M. and Stegun, I. (1970)
|
||||||
A weave implementation of std_norm_cdf, which is faster. this is unused,
|
#
|
||||||
because of the difficulties of a weave dependency. (see github issue #94)
|
# A weave implementation of std_norm_cdf, which is faster. this is unused,
|
||||||
|
# because of the difficulties of a weave dependency. (see github issue #94)
|
||||||
"""
|
#
|
||||||
#Generalize for many x
|
# """
|
||||||
x = np.asarray(x).copy()
|
# #Generalize for many x
|
||||||
cdf_x = np.zeros_like(x)
|
# x = np.asarray(x).copy()
|
||||||
N = x.size
|
# cdf_x = np.zeros_like(x)
|
||||||
support_code = "#include <math.h>"
|
# N = x.size
|
||||||
code = """
|
# support_code = "#include <math.h>"
|
||||||
|
# code = """
|
||||||
double sign, t, erf;
|
#
|
||||||
for (int i=0; i<N; i++){
|
# double sign, t, erf;
|
||||||
sign = 1.0;
|
# for (int i=0; i<N; i++){
|
||||||
if (x[i] < 0.0){
|
# sign = 1.0;
|
||||||
sign = -1.0;
|
# if (x[i] < 0.0){
|
||||||
x[i] = -x[i];
|
# sign = -1.0;
|
||||||
}
|
# x[i] = -x[i];
|
||||||
x[i] = x[i]/sqrt(2.0);
|
# }
|
||||||
|
# x[i] = x[i]/sqrt(2.0);
|
||||||
t = 1.0/(1.0 + 0.3275911*x[i]);
|
#
|
||||||
|
# t = 1.0/(1.0 + 0.3275911*x[i]);
|
||||||
erf = 1. - exp(-x[i]*x[i])*t*(0.254829592 + t*(-0.284496736 + t*(1.421413741 + t*(-1.453152027 + t*(1.061405429)))));
|
#
|
||||||
|
# erf = 1. - exp(-x[i]*x[i])*t*(0.254829592 + t*(-0.284496736 + t*(1.421413741 + t*(-1.453152027 + t*(1.061405429)))));
|
||||||
//return_val = 0.5*(1.0 + sign*erf);
|
#
|
||||||
cdf_x[i] = 0.5*(1.0 + sign*erf);
|
# //return_val = 0.5*(1.0 + sign*erf);
|
||||||
}
|
# cdf_x[i] = 0.5*(1.0 + sign*erf);
|
||||||
"""
|
# }
|
||||||
weave.inline(code, arg_names=['x', 'cdf_x', 'N'], support_code=support_code)
|
# """
|
||||||
return cdf_x
|
# weave.inline(code, arg_names=['x', 'cdf_x', 'N'], support_code=support_code)
|
||||||
|
# return cdf_x
|
||||||
|
|
||||||
def inv_std_norm_cdf(x):
|
def inv_std_norm_cdf(x):
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue