compute_params_to_lumerical_jacobian#
- Parametrization.compute_params_to_lumerical_jacobian(params: ndarray) ndarray#
Compute the Jacobian matrix dP[i]/dp[j] of the parametrization function using automatic differentiation.
The Jacobian J[i,j] represents the derivative of the output (geometric) property P[i] with respect to the optimization parameter p[j]. This uses autograd for exact derivatives (when available) or falls back to finite differences.
- Parameters:
- params
np.ndarray Parameter values at which to compute Jacobian.
- params
- Returns:
np.ndarrayJacobian matrix of shape (n_outputs, n_params) where n_outputs is the total number of scalar property values returned by the parametrization.
- Raises:
ValueErrorIf autograd is not available., or if result contains NaNs.
RuntimeErrorIf Jacobian computation fails.
Examples
>>> def my_func(p): ... return {"circle::radius": p[0], "rect::x": p[0] + p[1]} >>> geom = ParametrizedGeometry(my_func, bounds=[(0,1), (0,1)]) >>> J = geom.compute_params_to_lumerical_jacobian(np.array([0.5, 0.3])) >>> # J will be [[1.0, 0.0], # d(circle::radius)/dp >>> # [1.0, 1.0]] # d(rect::x)/dp