mirror of
https://github.com/SheffieldML/GPy.git
synced 2026-05-09 12:02:38 +02:00
Python 3 fixes
This commit is contained in:
parent
e58cc51c47
commit
e7d1277e62
17 changed files with 52 additions and 48 deletions
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
import numpy as np
|
||||
from .. import kern
|
||||
from bayesian_gplvm import BayesianGPLVM
|
||||
from .bayesian_gplvm import BayesianGPLVM
|
||||
from ..core.parameterization.variational import NormalPosterior, NormalPrior
|
||||
|
||||
class DPBayesianGPLVM(BayesianGPLVM):
|
||||
|
|
@ -15,5 +15,5 @@ class DPBayesianGPLVM(BayesianGPLVM):
|
|||
name='bayesian gplvm', mpi_comm=None, normalizer=None,
|
||||
missing_data=False, stochastic=False, batchsize=1):
|
||||
super(DPBayesianGPLVM,self).__init__(Y=Y, input_dim=input_dim, X=X, X_variance=X_variance, init=init, num_inducing=num_inducing, Z=Z, kernel=kernel, inference_method=inference_method, likelihood=likelihood, mpi_comm=mpi_comm, normalizer=normalizer, missing_data=missing_data, stochastic=stochastic, batchsize=batchsize, name='dp bayesian gplvm')
|
||||
self.X.mean.set_prior(X_prior)
|
||||
self.X.mean.set_prior(X_prior)
|
||||
self.link_parameter(X_prior)
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class GPRegression(GP):
|
|||
if kernel is None:
|
||||
kernel = kern.RBF(X.shape[1])
|
||||
|
||||
likelihood = likelihoods.Gaussian(variance=noise_var)
|
||||
likelihood = likelihoods.Gaussian(variance=noise_var)
|
||||
|
||||
super(GPRegression, self).__init__(X, Y, kernel, likelihood, name='GP regression', Y_metadata=Y_metadata, normalizer=normalizer)
|
||||
|
||||
|
|
|
|||
|
|
@ -228,14 +228,14 @@ class HessianChecker(GradientChecker):
|
|||
|
||||
if verbose:
|
||||
if block_indices:
|
||||
print "\nBlock {}".format(block_indices)
|
||||
print("\nBlock {}".format(block_indices))
|
||||
else:
|
||||
print "\nAll blocks"
|
||||
print("\nAll blocks")
|
||||
|
||||
header = ['Checked', 'Max-Ratio', 'Min-Ratio', 'Min-Difference', 'Max-Difference']
|
||||
header_string = map(lambda x: ' | '.join(header), [header])
|
||||
separator = '-' * len(header_string[0])
|
||||
print '\n'.join([header_string[0], separator])
|
||||
print('\n'.join([header_string[0], separator]))
|
||||
min_r = '%.6f' % float(numpy.min(ratio))
|
||||
max_r = '%.6f' % float(numpy.max(ratio))
|
||||
max_d = '%.6f' % float(numpy.max(difference))
|
||||
|
|
@ -248,7 +248,7 @@ class HessianChecker(GradientChecker):
|
|||
checked = "\033[91m False \033[0m"
|
||||
|
||||
grad_string = "{} | {} | {} | {} | {} ".format(checked, cols[0], cols[1], cols[2], cols[3])
|
||||
print grad_string
|
||||
print(grad_string)
|
||||
|
||||
if plot:
|
||||
import pylab as pb
|
||||
|
|
@ -348,7 +348,7 @@ class SkewChecker(HessianChecker):
|
|||
numeric_hess_partial = nd.Jacobian(self._df, vectorized=True)
|
||||
numeric_hess = numeric_hess_partial(x)
|
||||
|
||||
print "Done making numerical hessian"
|
||||
print("Done making numerical hessian")
|
||||
if analytic_hess.dtype is np.dtype('object'):
|
||||
#Blockify numeric_hess aswell
|
||||
blocksizes, pagesizes = get_block_shapes_3d(analytic_hess)
|
||||
|
|
@ -365,7 +365,7 @@ class SkewChecker(HessianChecker):
|
|||
#Unless super_plot is set, just plot the first one
|
||||
p = True if (plot and block_ind == numeric_hess.shape[2]-1) or super_plot else False
|
||||
if verbose:
|
||||
print "Checking derivative of hessian wrt parameter number {}".format(block_ind)
|
||||
print("Checking derivative of hessian wrt parameter number {}".format(block_ind))
|
||||
check_passed[block_ind] = self.checkgrad_block(analytic_hess[:,:,block_ind], numeric_hess[:,:,block_ind], verbose=verbose, step=step, tolerance=tolerance, block_indices=block_indices, plot=p)
|
||||
|
||||
current_index += current_size
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue