Skip to content

Commit 50f259c

Browse files
author
erdem-biyik
committed
dimensionality bug fix
1 parent d13b27d commit 50f259c

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

GP.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ def __init__(self, initialPoint=0, theta=0.1, noise_level=0.1):
1313
self.theta = theta #hyperparameter
1414
self.W = np.zeros((2,2)) #hessian at the queries
1515
self.noise = noise_level
16-
self.initialPoint = np.array([initialPoint]) #initial point that is set to have a 0 value
16+
self.initialPoint = np.array(initialPoint) #initial point that is set to have a 0 value
1717
self.dim = len(self.initialPoint) #number of features
1818

19-
2019
def updateParameters(self,query,answer):
2120
self.listQueries.append([query[0],query[1],answer])
2221
self.K = self.covK()

test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
def findBestQuery(gp):
66
def negative_info_gain(x):
77
return -1*gp.objectiveEntropy(x)
8-
x0 = np.array(gp.initialPoint*2) + np.random.rand(gp.dim*2)
8+
x0 = np.array(list(gp.initialPoint)*2) + np.random.rand(gp.dim*2)
99
# Let's now find the optimal query within the bounds (-2,2) for each dimension
1010
opt_res = opt.fmin_l_bfgs_b(negative_info_gain, x0=x0, bounds=[(-2,2)]*gp.dim*2, approx_grad=True, iprint=-1)
1111
return opt_res[0], -opt_res[1]
@@ -21,7 +21,7 @@ def negative_info_gain(x):
2121
print('posterior mean for the feature set [3,1] = ' + str(gp.mean1pt([3,1])))
2222
print('posterior covariance between the features [4,0] and [-1,1] = ' + str(gp.postcov([4,0],[-1,1])))
2323
print('posterior variance of the feature set [-2,1] = ' + str(gp.cov1pt([-2,1])))
24-
print('expected information gain from the query [0,0] vs [2,2] = ' + str(gp.objectiveEntropy([[0,0],[2,2]])))
24+
print('expected information gain from the query [0,0] vs [2,2] = ' + str(gp.objectiveEntropy([0,0,2,2])))
2525

2626
optimal_query, info_gain = findBestQuery(gp)
2727
print('optimal next query is ' + str(optimal_query))

0 commit comments

Comments
 (0)