Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugs in model update? #63

Open
fuku10 opened this issue Aug 18, 2022 · 1 comment
Open

Bugs in model update? #63

fuku10 opened this issue Aug 18, 2022 · 1 comment

Comments

@fuku10
Copy link

fuku10 commented Aug 18, 2022

Hello,
I found a strange behavior in model optimization of mgpr.py.

(1)
Is best_params["k_lengthscales"] = model.kernel.lengthscales
best_params["lengthscales"] = model.kernel.lengthscales ?

(2)
It seems that best_params is updated when optimizer.minimize(model.training_loss, model.trainable_variables) is executed. It means that the values of best_params always changes regardless of whether if loss < best_loss is True or False.

My environment is;
Python 3.7.12
tensorflow 2.9.1
gpflow 2.5.2
gym 0.18.0

Thanks,

@fuku10 fuku10 changed the title Bugs in Model update? Bugs in model update? Aug 18, 2022
@fuku10
Copy link
Author

fuku10 commented Aug 19, 2022

It seems that (2) was solved by using copy.deepcopy().

I added import copy and changed

            best_params = {
                "lengthscales" : model.kernel.lengthscales,
                "k_variance" : model.kernel.variance,
                "l_variance" : model.likelihood.variance}

to

           best_params = {
                "lengthscales" : copy.deepcopy(model.kernel.lengthscales),
                "k_variance" : copy.deepcopy(model.kernel.variance),
                "l_variance" : copy.deepcopy(model.likelihood.variance)}

Moreover, I changed

                    best_params["k_lengthscales"] = model.kernel.lengthscales
                    best_params["k_variance"] = model.kernel.variance
                    best_params["l_variance"] = model.likelihood.variance

to

                    best_params["lengthscales"] = copy.deepcopy(model.kernel.lengthscales) 
                    best_params["k_variance"] = copy.deepcopy(model.kernel.variance)
                    best_params["l_variance"] = copy.deepcopy(model.likelihood.variance)

(Note that "k_lengthscales" is also changed to "lengthscales".)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant