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

Fixing optimization variables #24

Open
maximilianmordig opened this issue Jun 30, 2018 · 1 comment
Open

Fixing optimization variables #24

maximilianmordig opened this issue Jun 30, 2018 · 1 comment

Comments

@maximilianmordig
Copy link

Hi,

I refer to the code at https://github.com/ICL-SML/Doubly-Stochastic-DGP/blob/master/demos/using_natural_gradients.ipynb, specifically:

ng_vars = [[model_nat_grads.layers[-1].q_mu, model_nat_grads.layers[-1].q_sqrt]]
for v in ng_vars[0]:
    v.set_trainable(False)
ng_action = NatGradOptimizer(gamma=1.).make_optimize_action(model_nat_grads, var_list=ng_vars)
adam_action = AdamOptimizer(0.001).make_optimize_action(model_nat_grads)
Loop([ng_action, adam_action], stop=iterations)()

Am I understanding correctly that the NatGradOptimizer ignores the set_trainable(False) whilst AdamOptimizer takes it into account? Is this because it acts at a lower level than GPFlow?

@maximilianmordig maximilianmordig changed the title Fixing variables Fixing optimization variables Jun 30, 2018
@hughsalimbeni
Copy link
Collaborator

The NatGradOptimizer optimizes only the variables in var_list, whereas all the tensorflow optimizers grab all variables with the trainable flag set to True. As you say, the NatGradOptimizer is a lower level implementation (it calls tf.assign directly, rather than let the tensorflow optimizer take care of it) as the update rule cannot be implemented through ordinary gradients.

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

2 participants