-
Notifications
You must be signed in to change notification settings - Fork 50
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
Add optimization direction to invdes.Optimizer
#1961
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just wondering about naming.. direction could be confused with eg ModeSource.direction. Is there a better option? Perhaps "max_or_min", sign (-1,1), or maximize:bool?
Yeah not sure. An alternative would be to do it the pytorch way and make it a |
how about we go the boolean route? |
Agree with everything. And let's just do Boolean. Only thing i can think of is are we ever going to want to support something other than minimizing or maximizing? Can't think of anything now so maybe let's just go with bool |
d331d0e
to
67fe9ca
Compare
There's one caveat to discuss. Penalties should always be minimized? If so then we want to apply the sign to the postprocess function value only. (In the objective function def) |
67fe9ca
to
2d2e7b6
Compare
updated it by passing |
tidy3d/plugins/invdes/optimizer.py
Outdated
@@ -130,7 +136,7 @@ def continue_run( | |||
post_process_val = aux_data["post_process_val"] | |||
|
|||
# update optimizer and parameters | |||
params, opt_state = self.update(parameters=params, state=opt_state, gradient=-grad) | |||
params, opt_state = self.update(parameters=params, state=opt_state, gradient=grad) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, if
direction_multiplier = 1 if maximize else -1
obj_fn_val = direction_multiplier * post_process_val - penalty_value
then shouldn't we be using -grad
here since we're always trying to maximize this quantity?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure it's pushed? just fyi
34acd6f
to
7feee7e
Compare
7feee7e
to
0d6bb41
Compare
@e-g-melo