Skip to content

Commit

Permalink
'modify'
Browse files Browse the repository at this point in the history
  • Loading branch information
smasky committed May 7, 2024
1 parent a2e6314 commit 85ec965
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
3 changes: 2 additions & 1 deletion UQPyL/problems/problem_ABC.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def _check_2d(self, X:np.ndarray):

def _check_bound(self,bound: np.ndarray):

if(not bound.shape[1]==self.n_input):
bound_tmp=bound.ravel()
if(not bound.shape[0]==self.n_input):
raise ValueError('the input bound is inconsistent with the input n_inputensions')

6 changes: 3 additions & 3 deletions UQPyL/surrogates/gp_kernels/base_kernel.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

class Gp_Kernel():
def __init__(self):
self._theta=None
self._theta_ub=None
self._theta_lb=None
self._theta={}
self._theta_ub={}
self._theta_lb={}

def __check_array__(self, value: Union[float,np.ndarray]):

Expand Down
42 changes: 21 additions & 21 deletions examples/example_surrogates.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@
#test set
X_test=lhs.sample(50, 10)
Y_test=problem.evaluate(X_test, unit=True)
###########################################

#############1. full_connect_neural_network (FNN)#################
print("#################full_connect_neural_network (FNN)#################")
from UQPyL.surrogates import FNN
#use 0-1 MinMaxScaler to normalize data
fnn=FNN(scalers=(MinMaxScaler(0,1), MinMaxScaler(0,1)),
hidden_layer_sizes=[16,32,64,32,16,8],
activation_functions='relu', solver='adam', alpha=0.001)
fnn.fit(X_train,Y_train)
Y_predict=fnn.predict(X_test)
#use R-square to validate the Y_predict and Y_test

r2=r2_score(Y_test, Y_predict)
print('r2:', r2)
#use rank_score to validate the Y_predict and Y_test

oe=rank_score(Y_test, Y_predict)
print('rank_score:', oe)

############2. gaussian_process (GP)#################
# ###########################################

# #############1. full_connect_neural_network (FNN)#################
# print("#################full_connect_neural_network (FNN)#################")
# from UQPyL.surrogates import FNN
# #use 0-1 MinMaxScaler to normalize data
# fnn=FNN(scalers=(MinMaxScaler(0,1), MinMaxScaler(0,1)),
# hidden_layer_sizes=[16,32,64,32,16,8],
# activation_functions='relu', solver='adam', alpha=0.001)
# fnn.fit(X_train,Y_train)
# Y_predict=fnn.predict(X_test)
# #use R-square to validate the Y_predict and Y_test

# r2=r2_score(Y_test, Y_predict)
# print('r2:', r2)
# #use rank_score to validate the Y_predict and Y_test

# oe=rank_score(Y_test, Y_predict)
# print('rank_score:', oe)

# ############2. gaussian_process (GP)#################
print("#################gaussian_process (GP)#################")
from UQPyL.surrogates.gaussian_process import GPR
# we should construct a kernel for GPR
Expand Down

0 comments on commit 85ec965

Please sign in to comment.