Object
The primary object in the package is kkthn.builder.KKTHardNet.
For the configuration associated with this object, see Hyperparameters.
Role of the object
KKTHardNet is responsible for:
storing symbolic parameters, inverse parameters, and variables,
recording objectives and constraints,
attaching CSV datasets,
training supervised, unsupervised, and inverse-estimation workflows,
saving model artifacts,
loading saved runs,
predicting with JAX or native projection backends.
Autodoc
- class kkthn.builder.KKTHardNet(name: str = 'kkthardnet', *, train: dict[str, Any] | KKTTrainConfig | None = None, projection: dict[str, Any] | ProjectionSettings | None = None)[source]
Bases:
object- __init__(name: str = 'kkthardnet', *, train: dict[str, Any] | KKTTrainConfig | None = None, projection: dict[str, Any] | ProjectionSettings | None = None) None[source]
- add_parameter(names: str | Iterable[str])[source]
- add_variable(names: str | Iterable[str])[source]
- add_inverse_parameter(names: str | Iterable[str], *, init_value: float | Iterable[float] | None = None)[source]
- extract(path: str | Path) dict[str, Constant][source]
Load arrays from a
.npzfile and expose them as model attributes.
- dataset(*, parameters: str | Path, variables: str | Path | None = None) KKTHardNet[source]
- set_dataset(*, parameters: str | Path, variables: str | Path | None = None) KKTHardNet[source]
- use_dataset(*, parameters: str | Path, variables: str | Path | None = None) KKTHardNet[source]
- set_train_config(config: dict[str, Any] | KKTTrainConfig) KKTHardNet[source]
- set_projection_config(config: dict[str, Any] | ProjectionSettings) KKTHardNet[source]
- model(*, train: dict[str, Any] | KKTTrainConfig | None = None, projection: dict[str, Any] | ProjectionSettings | None = None) dict[str, Any][source]
- optimize(*, train: dict[str, Any] | KKTTrainConfig | None = None, projection: dict[str, Any] | ProjectionSettings | None = None) dict[str, Any][source]
- estimate(*, train: dict[str, Any] | KKTTrainConfig | None = None, projection: dict[str, Any] | ProjectionSettings | None = None) dict[str, Any][source]
- load(metadata_path: str | Path, *, verbose: bool | None = None) KKTHardNet[source]
- predict(values, *, projection_backend: str = 'jax') ndarray[source]
- summary() dict[str, Any][source]
Print a compact summary of the current completed or loaded run.
- plot_history(*, show: bool = True, save_dir: str | Path | None = None, bg: str = 'grey')[source]
Plot and save MSE/loss and constraint violation histories.
- lin(matrix, expr)[source]
Form
A @ exprfrom an extracted or registered matrix/vector.
- batch_lin(matrix, expr)[source]
Form a vector expression from a 2D matrix and vector expression.
- quad(matrix, expr) Expression[source]
Form
expr.T @ Q @ expr.
- batch_quad(tensor, expr) VectorExpression[source]
Form batched quadratic expressions from a rank-3 tensor.
- batch_exp(expr) VectorExpression[source]
- sin(expr)[source]
- cos(expr)[source]
- exp(expr)[source]
- log(expr)[source]
- sqrt(expr)[source]
- abs(expr)[source]