Predict
Prediction functions for ndarrays of device geometries.
predict_array(device_array, model, model_type, binarize, gpu=False)
Predict the nanofabrication outcome of a device array using a specified model.
This function sends the device array to a serverless prediction service, which uses a specified machine learning model to predict the outcome of the nanofabrication process. The prediction can be performed on a GPU if specified.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device_array
|
ndarray
|
A 2D array representing the planar geometry of the device. This array undergoes various transformations to predict the nanofabrication process. |
required |
model
|
Model
|
The model to use for prediction, representing a specific fabrication process and
dataset. This model encapsulates details about the fabrication foundry, process,
material, technology, thickness, and sidewall presence, as defined in
|
required |
model_type
|
str
|
The type of model to use (e.g., 'p' for prediction, 'c' for correction, or 's' for SEMulate). |
required |
binarize
|
bool
|
If True, the predicted device geometry will be binarized using a threshold method. This is useful for converting probabilistic predictions into binary geometries. |
required |
gpu
|
bool
|
If True, the prediction will be performed on a GPU. Defaults to False. Note: The GPU option has more startup overhead and will take longer for small devices, but will be faster for larger devices. |
False
|
Returns:
Type | Description |
---|---|
ndarray
|
The predicted output array. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the request to the prediction service fails. |
Source code in prefab/predict.py
predict_array_with_grad(device_array, model)
Predict the nanofabrication outcome of a device array and compute its gradient.
This function predicts the outcome of the nanofabrication process for a given device array using a specified model. It also computes the gradient of the prediction with respect to the input device array, making it suitable for use in automatic differentiation applications (e.g., autograd).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
device_array
|
ndarray
|
A 2D array representing the planar geometry of the device. |
required |
model
|
Model
|
The model to use for prediction, representing a specific fabrication process. |
required |
Returns:
Type | Description |
---|---|
ndarray
|
The predicted output array. |
Source code in prefab/predict.py
predict_array_with_grad_vjp(ans, x)
Define the vector-Jacobian product (VJP) for the prediction function.
This function provides the VJP for the predict_array_with_grad
function,
which is used in reverse-mode automatic differentiation to compute gradients.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ans
|
ndarray
|
The output of the |
required |
x
|
ndarray
|
The input device array for which the gradient is computed. |
required |
Returns:
Type | Description |
---|---|
function
|
A function that computes the VJP given an upstream gradient |