Documentation
¶
Overview ¶
Package bsplines provide a GoMLX version of github.com/gomlx/bsplines: it provides evaluation of bsplines curves, that can be used as layers. Currently, it's best used through `gomlx/ml/layers/kan` package.
It returns a computation graph that can be combined/used on other computations, e.g., to implement calibration layers for input of neural-networks, or for "KAN - Kolmogorov-Arnold Networks" [1]
It is meant to work for batches of inputs, each example with multiple inputs and outputs, pay special attention to the shapes of the control points, inputs and outputs. They are documented in the [Evaluator] function.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Evaluate ¶
Evaluate creates the computation graph to evaluate the B-splines defined by b (it's used only for the knots) and the controlPoints at the inputs values. Notice b and controlPoints defined multiple B-splines, see description below.
Parameters:
- b: bsplines.BSpline with the specification of the B-spline. The control points in b is ignored, instead this uses the explicitly passed controlPoints.
- inputs: tensor (graph.Node) with shape `[batchSize, numInputs]`: the B-spline functions are evaluated on each of the examples (batchSize is the number of examples). Per example there are numInputs inputs, each one gets its own B-spline, each has its own control points. If inputs is a scalar value, it is automatically expanded to shape `[batchSize=1, numInputs=1]`. Notice the dtype of inputs must match the dtype of controlPoints.
- controlPoints: tensor (graph.Node) with shape `[numInputs, numOutputs, numControlPoints]`. There are effectively numInputs*numOutputs B-splines defined, each of these takes numControlPoints. And `numControlPoints` must match `b.NumControlPoints()`. If controlPoints is rank 1, it is expanded to shape `[numInputs=1, numOutputs=1, numControlPoints]`. Any other rank is assumed to be an error. Notice the dtype of controlPoints must match the dtype of inputs.
The returned tensor (graph.Node) is shaped `[batchSize, numOutputs, numInputs]`. Each example in the batch is evaluated by numOutputs*numInputs B-spline functions.
If the inputs tensor was a scalar, and numInputs==1 and numOutput==1, it returns a scalar as well -- for individual points inference, useful for testing.
Types ¶
This section is empty.