Automatic Differentiation with Autograd

Automatic Differentiation with Autograd#

Differential Operators#

tidy3d.plugins.autograd.differential_operators.grad(fun)

Returns a function that computes the gradient of fun with respect to x.

tidy3d.plugins.autograd.differential_operators.value_and_grad(fun)

Returns a function that computes both the value and gradient of fun with respect to x.

Functions#

tidy3d.plugins.autograd.functions.add_at(x,ย ...)

Add values to specified indices of an array.

tidy3d.plugins.autograd.functions.convolve(...)

Convolve an array with a given kernel.

tidy3d.plugins.autograd.functions.grey_closing(array)

Perform grey closing on an array.

tidy3d.plugins.autograd.functions.grey_dilation(...)

Perform grey dilation on an array.

tidy3d.plugins.autograd.functions.grey_erosion(array)

Perform grey erosion on an array.

tidy3d.plugins.autograd.functions.grey_opening(array)

Perform grey opening on an array.

tidy3d.plugins.autograd.functions.interpn(...)

Interpolate over a rectilinear grid in arbitrary dimensions.

tidy3d.plugins.autograd.functions.least_squares(...)

Perform least squares fitting to find the best-fit parameters for a model function.

tidy3d.plugins.autograd.functions.morphological_gradient(array)

Compute the morphological gradient of an array.

tidy3d.plugins.autograd.functions.morphological_gradient_external(array)

Compute the external morphological gradient of an array.

tidy3d.plugins.autograd.functions.morphological_gradient_internal(array)

Compute the internal morphological gradient of an array.

tidy3d.plugins.autograd.functions.pad(array,ย ...)

Pad an array along specified axes with a given mode and padding width.

tidy3d.plugins.autograd.functions.rescale(...)

Rescale an array from an arbitrary input range to an arbitrary output range.

tidy3d.plugins.autograd.functions.smooth_max(x)

Compute the smooth maximum of an array using temperature parameter tau.

tidy3d.plugins.autograd.functions.smooth_min(x)

Compute the smooth minimum of an array using temperature parameter tau.

tidy3d.plugins.autograd.functions.threshold(array)

Apply a threshold to an array, setting values below the threshold to vmin and values above to vmax.

tidy3d.plugins.autograd.functions.trapz(y[,ย ...])

Integrate along the given axis using the composite trapezoidal rule.

Utilities#

tidy3d.plugins.autograd.utilities.chain(*funcs)

Chain multiple functions together to apply them sequentially to an array.

tidy3d.plugins.autograd.utilities.get_kernel_size_px([...])

Calculate the kernel size in pixels based on the provided radius and grid spacing.

tidy3d.plugins.autograd.utilities.make_kernel(...)

Create a kernel based on the specified type in n dimensions.

tidy3d.plugins.autograd.utilities.scalar_objective([...])

Decorator to ensure the objective function returns a real scalar value.

Primitives#

tidy3d.plugins.autograd.primitives.gaussian_filter(...)

Multidimensional Gaussian filter.

tidy3d.plugins.autograd.primitives.interpolate_spline(...)

Differentiable spline interpolation of a given order with optional endpoint derivatives.

Inverse Design#

tidy3d.plugins.autograd.invdes.CircularFilter

A circular filter for creating and applying convolution filters.

tidy3d.plugins.autograd.invdes.ConicFilter

A conic filter for creating and applying convolution filters.

tidy3d.plugins.autograd.invdes.ErosionDilationPenalty

A class that computes a penalty for erosion/dilation of a parameter map not being unity.

tidy3d.plugins.autograd.invdes.FilterAndProject

A class that combines filtering and projection operations.

tidy3d.plugins.autograd.invdes.grey_indicator(array)

Calculate the grey indicator for a given array.

tidy3d.plugins.autograd.invdes.make_circular_filter([...])

make_filter() with a default filter_type value of circular.

tidy3d.plugins.autograd.invdes.make_conic_filter([...])

make_filter() with a default filter_type value of conic.

tidy3d.plugins.autograd.invdes.make_curvature_penalty(...)

Create a penalty function based on the curvature of a set of points.

tidy3d.plugins.autograd.invdes.make_erosion_dilation_penalty(...)

Computes a penalty for erosion/dilation of a parameter map not being unity.

tidy3d.plugins.autograd.invdes.make_filter([...])

Create a filter function based on the specified kernel type and size.

tidy3d.plugins.autograd.invdes.make_filter_and_project([...])

Create a function that filters and projects an array.

tidy3d.plugins.autograd.invdes.ramp_projection(array)

Apply a piecewise linear ramp projection to an array.

tidy3d.plugins.autograd.invdes.tanh_projection(array)

Apply a tanh-based soft-thresholding projection to an array.