You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using automatic differentiation, there is a subtle issue with automatically differentiating objective functions with respect to a variable which appears in conditional expressions.
For example, differentiating an objective function |Ey|(z) which calculates the y-component of the electric field as a function of z-position for a fixed simulation (layers, lattice, permittivity, etc.). At the z values of the layer boundaries, the derivative might not be well-defined due to inkstone conditionally selecting the right-most (larger z) layer as the layer in which the boundary z belongs. Since autodiff libraries don't know about the control flow (they only trace inside the if statements), they will still output a gradient without throwing errors, even though the gradient is ill-defined. Away from the layer boundaries, autodiff can differentiate through the control flow and the z-derivatives are consistent with finite difference.
To fix, some smoothing function could be used instead of the z-value-layer check in GetFieldsListPoints.
The text was updated successfully, but these errors were encountered:
When using automatic differentiation, there is a subtle issue with automatically differentiating objective functions with respect to a variable which appears in conditional expressions.
For example, differentiating an objective function |Ey|(z) which calculates the y-component of the electric field as a function of z-position for a fixed simulation (layers, lattice, permittivity, etc.). At the z values of the layer boundaries, the derivative might not be well-defined due to inkstone conditionally selecting the right-most (larger z) layer as the layer in which the boundary z belongs. Since autodiff libraries don't know about the control flow (they only trace inside the
if
statements), they will still output a gradient without throwing errors, even though the gradient is ill-defined. Away from the layer boundaries, autodiff can differentiate through the control flow and the z-derivatives are consistent with finite difference.To fix, some smoothing function could be used instead of the z-value-layer check in
GetFieldsListPoints
.The text was updated successfully, but these errors were encountered: