amisc.interpolator
Provides interpolator classes. Interpolators approximate the input → output mapping of a model given a set of training data. The training data consists of input-output pairs, and the interpolator can be refined with new training data.
Includes:
Interpolator
: Abstract class providing basic structure of an interpolatorLagrange
: Concrete implementation for tensor-product barycentric Lagrange interpolationInterpolatorState
: Interface for a dataclass that stores the internal state of an interpolatorLagrangeState
: The internal state for a barycentric Lagrange polynomial interpolator
Interpolator
Bases: Serializable
, ABC
Interface for an interpolator object that approximates a model. An interpolator should:
refine
- take an old state and new training data and produce a new "refined" state (e.g. new weights/biases)predict
- interpolate from the training data to a new set of points (i.e. approximate the underlying model)gradient
- compute the grdient/Jacobian at new points (if you want)hessian
- compute the 2nd derivative/Hessian at new points (if you want)
Currently, only the Lagrange
interpolator is supported and can be constructed from a configuration dict
via Interpolator.from_dict()
.
from_dict(config)
classmethod
Create an Interpolator
object from a dict
config. Only method='lagrange'
is supported for now.
Source code in src/amisc/interpolator.py
gradient(x, state, training_data)
abstractmethod
Evaluate the gradient/Jacobian at points x
using the interpolator.
PARAMETER | DESCRIPTION |
---|---|
x |
the input Dataset
TYPE:
|
state |
the current state of the interpolator
TYPE:
|
training_data |
a tuple of |
RETURNS | DESCRIPTION |
---|---|
Dataset
|
a Dataset |
Source code in src/amisc/interpolator.py
hessian(x, state, training_data)
abstractmethod
Evaluate the Hessian at points x
using the interpolator.
PARAMETER | DESCRIPTION |
---|---|
x |
the input Dataset
TYPE:
|
state |
the current state of the interpolator
TYPE:
|
training_data |
a tuple of |
RETURNS | DESCRIPTION |
---|---|
Dataset
|
a Dataset |
Source code in src/amisc/interpolator.py
predict(x, state, training_data)
abstractmethod
Interpolate the output of the model at points x
using the given state and training data
PARAMETER | DESCRIPTION |
---|---|
x |
the input Dataset
TYPE:
|
state |
the current state of the interpolator
TYPE:
|
training_data |
a tuple of |
RETURNS | DESCRIPTION |
---|---|
Dataset
|
a Dataset |
Source code in src/amisc/interpolator.py
refine(beta, training_data, old_state, input_domains)
abstractmethod
Refine the interpolator state with new training data.
PARAMETER | DESCRIPTION |
---|---|
beta |
a multi-index specifying the fidelity "levels" of the new interpolator state (starts at (0,... 0))
TYPE:
|
training_data |
a tuple of |
old_state |
the previous state of the interpolator (None if initializing the first state)
TYPE:
|
input_domains |
a
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
InterpolatorState
|
the new "refined" interpolator state |
Source code in src/amisc/interpolator.py
InterpolatorState
Bases: Serializable
, ABC
Interface for a dataclass that stores the internal state of an interpolator (e.g. weights and biases).
Lagrange(interval_capacity=4.0)
dataclass
Bases: Interpolator
, StringSerializable
Implementation of a tensor-product barycentric Lagrange polynomial interpolator. A LagrangeState
stores
the 1d interpolation grids and weights for each input dimension. Lagrange
computes the tensor-product
of 1d Lagrange polynomials to approximate a multi-variate function.
ATTRIBUTE | DESCRIPTION |
---|---|
interval_capacity |
tuning knob for Lagrange interpolation (see Berrut and Trefethen 2004)
TYPE:
|
gradient(x, state, training_data)
Evaluate the gradient/Jacobian at points x
using the interpolator.
Source code in src/amisc/interpolator.py
hessian(x, state, training_data)
Evaluate the Hessian at points x
using the interpolator.
Source code in src/amisc/interpolator.py
342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 |
|
predict(x, state, training_data)
Predict the output of the model at points x
with barycentric Lagrange interpolation.
Source code in src/amisc/interpolator.py
refine(beta, training_data, old_state, input_domains)
Refine the interpolator state with new training data.
PARAMETER | DESCRIPTION |
---|---|
beta |
the refinement level indices for the interpolator (not used for
TYPE:
|
training_data |
a tuple of dictionaries containing the new training data ( |
old_state |
the old interpolator state to refine (None if initializing)
TYPE:
|
input_domains |
a
TYPE:
|
RETURNS | DESCRIPTION |
---|---|
LagrangeState
|
the new interpolator state |
Source code in src/amisc/interpolator.py
LagrangeState(weights=dict(), x_grids=dict())
dataclass
Bases: InterpolatorState
, Base64Serializable
The internal state for a barycentric Lagrange polynomial interpolator.
ATTRIBUTE | DESCRIPTION |
---|---|
weights |
the 1d interpolation grid weights
TYPE:
|
x_grids |
the 1d interpolation grids
TYPE:
|