Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MeLOn - Machine Learning Models for Optimization
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AVT-SVT
public
MeLOn - Machine Learning Models for Optimization
Commits
f81eca75
Commit
f81eca75
authored
1 year ago
by
jannik.luethje
Browse files
Options
Downloads
Patches
Plain Diff
Release version 0.0.11
parent
74856516
No related branches found
Branches containing commit
Tags
0.0.11
Tags containing commit
No related merge requests found
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
dep/mcpp
+1
-1
1 addition, 1 deletion
dep/mcpp
gaussian process/training/python/utils.py
+21
-4
21 additions, 4 deletions
gaussian process/training/python/utils.py
with
22 additions
and
5 deletions
mcpp
@
fb61bbb8
Compare
69a763e5
...
fb61bbb8
Subproject commit
69a763e55faf6557af0839a06fa82eb919b
062
e4
Subproject commit
fb61bbb8733b23a0b48cb86f016429594ee
062
c5
This diff is collapsed.
Click to expand it.
gaussian process/training/python/utils.py
+
21
−
4
View file @
f81eca75
...
@@ -4,6 +4,7 @@ from pathlib import Path
...
@@ -4,6 +4,7 @@ from pathlib import Path
import
json
import
json
import
torch
import
torch
from
gpytorch.means
import
ConstantMean
,
ZeroMean
from
gpytorch.means
import
ConstantMean
,
ZeroMean
from
gpytorch.likelihoods
import
GaussianLikelihood
,
FixedNoiseGaussianLikelihood
# Import MeLOn
# Import MeLOn
import
maingopy.melonpy
as
melonpy
import
maingopy.melonpy
as
melonpy
# If you are not getting MeLOn through MAiNGO, use:
# If you are not getting MeLOn through MAiNGO, use:
...
@@ -51,8 +52,16 @@ def generate_melon_gp_object(GP_model, GP_likelihood, X, y, matern, scaler):
...
@@ -51,8 +52,16 @@ def generate_melon_gp_object(GP_model, GP_likelihood, X, y, matern, scaler):
noise
=
GP_likelihood
.
noise
.
detach
().
numpy
()
noise
=
GP_likelihood
.
noise
.
detach
().
numpy
()
cov_mat
=
GP_model
.
covar_module
(
X
)
cov_mat
=
GP_model
.
covar_module
(
X
)
gp_data
.
K
=
cov_mat
.
numpy
()
+
noise
*
np
.
eye
(
N
=
gp_data
.
nX
)
gp_data
.
invK
=
np
.
linalg
.
inv
(
gp_data
.
K
)
if
isinstance
(
GP_likelihood
,
GaussianLikelihood
):
K_numpy
=
cov_mat
.
numpy
()
+
noise
*
np
.
eye
(
N
=
gp_data
.
nX
)
elif
isinstance
(
GP_likelihood
,
FixedNoiseGaussianLikelihood
):
K_numpy
=
cov_mat
.
numpy
()
+
np
.
diag
(
noise
)
else
:
raise
Exception
(
f
'
Likelihood
{
type
(
GP_likelihood
)
}
currently not supported.
'
)
gp_data
.
K
=
K_numpy
gp_data
.
invK
=
np
.
linalg
.
inv
(
K_numpy
)
gp_data
.
matern
=
matern
gp_data
.
matern
=
matern
kernel_data
=
melonpy
.
KernelData
()
kernel_data
=
melonpy
.
KernelData
()
...
@@ -106,8 +115,16 @@ def save_model_to_json(filepath, filename, GP_model, GP_likelihood, X, y, matern
...
@@ -106,8 +115,16 @@ def save_model_to_json(filepath, filename, GP_model, GP_likelihood, X, y, matern
noise
=
GP_likelihood
.
noise
.
detach
().
numpy
()
noise
=
GP_likelihood
.
noise
.
detach
().
numpy
()
cov_mat
=
GP_model
.
covar_module
(
X
).
numpy
()
cov_mat
=
GP_model
.
covar_module
(
X
).
numpy
()
prediction_parameters
[
"
K
"
]
=
(
cov_mat
+
noise
*
np
.
eye
(
N
=
prediction_parameters
[
"
nX
"
])).
tolist
()
prediction_parameters
[
"
invK
"
]
=
np
.
linalg
.
inv
(
cov_mat
+
noise
*
np
.
eye
(
N
=
prediction_parameters
[
"
nX
"
])).
tolist
()
if
isinstance
(
GP_likelihood
,
GaussianLikelihood
):
K_numpy
=
cov_mat
.
numpy
()
+
noise
*
np
.
eye
(
N
=
prediction_parameters
[
"
nX
"
])
elif
isinstance
(
GP_likelihood
,
FixedNoiseGaussianLikelihood
):
K_numpy
=
cov_mat
.
numpy
()
+
np
.
diag
(
noise
)
else
:
raise
Exception
(
f
'
Likelihood
{
type
(
GP_likelihood
)
}
currently not supported.
'
)
prediction_parameters
[
"
K
"
]
=
K_numpy
.
tolist
()
prediction_parameters
[
"
invK
"
]
=
np
.
linalg
.
inv
(
K_numpy
).
tolist
()
if
not
'
input
'
in
scalers
or
not
isinstance
(
scalers
[
'
input
'
],
MinMaxScaler
):
if
not
'
input
'
in
scalers
or
not
isinstance
(
scalers
[
'
input
'
],
MinMaxScaler
):
raise
Exception
(
"
There has to be an inputscaler which is a scikit-learn MinMaxScaler instance
"
)
raise
Exception
(
"
There has to be an inputscaler which is a scikit-learn MinMaxScaler instance
"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment