Optimize within an accuracy limit
optimizeShrink and retrain a model to fit a target chip's memory limits within your accuracy tolerance, using your own data.
Instructions
Find the smallest model for the chip within your accuracy limit, retrained on your data. Runs on the service for 5-60 minutes, so this returns right away with the run id and its place in the queue: then call wait_for_run(run_id) (again while it says still running), and download(run_id) when it passes. The data is used for this run only and deleted when it ends.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"model_path": "<model_path>",
"data_path": "<data_path>",
"chip": "<chip>"
},
"name": "optimize"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| chip | Yes | A chip name from list_chips. | |
| effort | No | 'quick' (about 15 minutes) or 'thorough' (up to an hour; not on the trial). | quick |
| output | No | 'classes' for class scores; 'values' for detectors, autoencoders and regression (y not needed). | classes |
| ram_kb | No | SRAM budget in KB (default: the chip's). | |
| flash_kb | No | Flash budget in KB (default: the chip's). | |
| minimize | No | What to shrink: SRAM ('ram'), flash, or both. | ram |
| data_path | Yes | The data: an .npz (X, y) or a .zip of image folders, one per class. Run check_data first. | |
| model_path | Yes | The trained model: .tflite or .onnx, or a .zip of a firmware export. | |
| check_first | No | Run the local data check first and stop on problems. | |
| image_scaling | No | Image zips only: how the model expects pixels. 'auto' = as the model says (int8 .tflite files carry it). | auto |
| accuracy_limit | No | How many points of accuracy the result may lose against your model, on the test part of the data. |