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, device_array, *args)
Define the vector-Jacobian product (VJP) for the prediction function.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ans
|
ndarray
|
The output of the |
required |
device_array
|
ndarray
|
The input device array for which the gradient is computed. |
required |
*args
|
Additional arguments that aren't used in the VJP computation. |
()
|
Returns:
Type | Description |
---|---|
function
|
A function that computes the VJP given an upstream gradient |
Source code in prefab/predict.py
predict_gdstk(gdstk_cell, model, model_type, gds_layer=(1, 0), eta=0.5)
Predict the nanofabrication outcome of a gdstk cell using a specified model.
This function extracts polygons from a gdstk cell, sends them to the prediction server, and returns a new cell containing the predicted polygons.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
gdstk_cell
|
Cell
|
The gdstk.Cell object containing polygons to predict. |
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 ('p' for prediction, 'c' for correction). |
required |
gds_layer
|
tuple[int, int]
|
The layer and datatype to use within the GDSTK cell. Defaults to (1, 0). |
(1, 0)
|
eta
|
float
|
The threshold value for binarization. Defaults to 0.5. Because intermediate values cannot be preserved in the polygon data, the predicted polygons are binarized using a threshold value of eta. |
0.5
|
Returns:
Type | Description |
---|---|
Cell
|
A new gdstk cell containing the predicted polygons. For multi-level predictions, each level's polygons will be placed on a different layer: - Level 0: (layer, 99) - Level 1: (layer, 100) |
Raises:
Type | Description |
---|---|
ValueError
|
If no polygons are found in the specified layer. |
Source code in prefab/predict.py
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
|