Utilities, Serialization & Parallelism
Overview
- Serialization helpers let you persist tensors, estimator state, and module payloads in JSON-friendly forms.
- WorkerPool provides a structured API for bounded parallel execution and status inspection.
- check_array, check_X_y, and check_is_fitted support scikit-learn-style validation flows in custom estimators.
WorkerPool
A pool of worker threads for parallel task execution.
Get the number of available CPU cores.
Create a WorkerPool with sensible defaults.
Deserialize a JSON string back to a payload object.
Load a serialized payload from a file (Node.js only).
Save a serialized payload to a file (Node.js only).
Serialize a payload to a JSON string.
Input validation on an array-like (Tensor).
Check that an estimator has been fitted.
Input validation for standard estimators (X and y).
Get TypedArray constructor for a given DType.
Ensure a dtype is numeric (non-string).
Normalize a list of axes to valid dimension indices.
Normalize an axis argument to a valid dimension index.
shapeToSize is exported by deepbox/core.
Validate that a value is an array.
validateDevice is exported by deepbox/core.
validateDtype is exported by deepbox/core.
Validate that a value is a safe integer.
Validate that a value is non-negative (>= 0).
Validate that a value is one of the allowed options.
Validate that a value is positive (> 0).
Validate that a value is within a specified range [min, max].
validateShape is exported by deepbox/core.
import { availableCores, createWorkerPool, save, toJSON,} from "deepbox/core";const payload = { __type: "Tensor", data: [1, 2, 3, 4], shape: [2, 2], dtype: "float32",} as const;console.log(toJSON(payload));await save("tensor.json", payload);const pool = createWorkerPool(Math.min(availableCores(), 4));console.log(pool.status());