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

More autograd helpers #2055

Merged
merged 3 commits into from
Nov 5, 2024
Merged

More autograd helpers #2055

merged 3 commits into from
Nov 5, 2024

Conversation

yaugenst-flex
Copy link
Collaborator

  • Removes DeprecationWarning of DataArray.values.
  • Adds smooth_min, smooth_max, and least_squares implementations to plugins.autograd.functions.
  • Adds @scalar_objective decorator that extracts DataArray.data and performs some additional checks on the output data of objective functions. If an objective function is decorated with this, calling DataArray.values within the objective function is not necessary anymore. Our grad and value_and_grad implementations in plugins.autograd wrap objective functions with this decorator automatically.
  • Some internal refactoring of the pad function.
  • Some test refactoring to reduce the no. of function calls for grad checks.

@yaugenst-flex yaugenst-flex self-assigned this Nov 4, 2024
Copy link
Collaborator

@tylerflex tylerflex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! think at some point we should include all of these in our demo notebooks. Just a few minor comments.

CHANGELOG.md Show resolved Hide resolved
CHANGELOG.md Show resolved Hide resolved
tidy3d/components/data/data_array.py Show resolved Hide resolved
tidy3d/plugins/autograd/differential_operators.py Outdated Show resolved Hide resolved
tidy3d/plugins/autograd/functions.py Show resolved Hide resolved
tidy3d/plugins/autograd/utilities.py Show resolved Hide resolved
tidy3d/plugins/autograd/utilities.py Outdated Show resolved Hide resolved
tidy3d/plugins/autograd/utilities.py Outdated Show resolved Hide resolved
@momchil-flex momchil-flex added the 2.7 will go into version 2.7.* label Nov 5, 2024
@yaugenst-flex yaugenst-flex merged commit 6da4072 into develop Nov 5, 2024
15 checks passed
@yaugenst-flex yaugenst-flex deleted the autograd branch November 5, 2024 16:58
@e-g-melo
Copy link
Collaborator

e-g-melo commented Nov 7, 2024

Hi @yaugenst-flex! I wonder if we can serialize the softmin and softmax functions. It would be nice to include them in GUI.

@yaugenst-flex
Copy link
Collaborator Author

Hey @e-g-melo, the thing is that we currently do not have support for n-ary operators. Currently, every metric is restricted to be scalar. I will look into it though, this is on the todo list.

@e-g-melo
Copy link
Collaborator

e-g-melo commented Nov 7, 2024

Hey @e-g-melo, the thing is that we currently do not have support for n-ary operators. Currently, every metric is restricted to be scalar. I will look into it though, this is on the todo list.

I've created a GUI version of this notebook, which has a different softmin function.

image

In GUI, we can make it like this:

image

3*(m1*exp(-m1)/(exp(-m1)+exp(-m2)+exp(-m3)) + m2*exp(-m2)/(exp(-m1)+exp(-m2)+exp(-m3)) + m3*exp(-m3)/(exp(-m1)+exp(-m2)+exp(-m3)))

I wonder if we could have something simple, like softmin([m1, m2, m3])

@e-g-melo
Copy link
Collaborator

e-g-melo commented Nov 7, 2024

Oh.. I saw your comment on Tom's notebook. Anyway, we can wait, no worries.

@yaugenst-flex
Copy link
Collaborator Author

Yeah we can definitely add that, and it's also the goal to have these more generic functions. But I still have to figure out a good interface for them..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.7 will go into version 2.7.*
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants