Warning: This project is deprecated. TensorFlow Addons has stopped development,
The project will only be providing minimal maintenance releases until May 2024. See the full
announcement here or on
github.
tfa.image.interpolate_spline
Stay organized with collections
Save and categorize content based on your preferences.
Interpolate signal using polyharmonic interpolation.
tfa.image.interpolate_spline(
train_points: tfa.types.TensorLike
,
train_values: tfa.types.TensorLike
,
query_points: tfa.types.TensorLike
,
order: int,
regularization_weight: tfa.types.FloatTensorLike
= 0.0,
name: str = 'interpolate_spline'
) -> tf.Tensor
The interpolant has the form
\[f(x) = \sum_{i = 1}^n w_i \phi(||x - c_i||) + v^T x + b.\]
This is a sum of two terms: (1) a weighted sum of radial basis function
(RBF) terms, with the centers \(c_1, ... c_n\), and (2) a linear term
with a bias. The \(c_i\) vectors are 'training' points.
In the code, b is absorbed into v
by appending 1 as a final dimension to x. The coefficients w and v are
estimated such that the interpolant exactly fits the value of the function
at the \(c_i\) points, the vector w is orthogonal to each \(c_i\),
and the vector w sums to 0. With these constraints, the coefficients
can be obtained by solving a linear system.
\(\phi\) is an RBF, parametrized by an interpolation
order. Using order=2 produces the well-known thin-plate spline.
We also provide the option to perform regularized interpolation. Here, the
interpolant is selected to trade off between the squared loss on the
training data and a certain measure of its curvature
(details).
Using a regularization weight greater than zero has the effect that the
interpolant will no longer exactly fit the training data. However, it may
be less vulnerable to overfitting, particularly for high-order
interpolation.
Note the interpolation procedure is differentiable with respect to all
inputs besides the order parameter.
We support dynamically-shaped inputs, where batch_size, n, and m are None
at graph construction time. However, d and k must be known.
Args |
train_points
|
[batch_size, n, d] float Tensor of n d-dimensional
locations. These do not need to be regularly-spaced.
|
train_values
|
[batch_size, n, k] float Tensor of n c-dimensional
values evaluated at train_points.
|
query_points
|
[batch_size, m, d] Tensor of m d-dimensional locations
where we will output the interpolant's values.
|
order
|
order of the interpolation. Common values are 1 for
\(\phi(r) = r\), 2 for \(\phi(r) = r^2 * log(r)\)
(thin-plate spline), or 3 for \(\phi(r) = r^3\).
|
regularization_weight
|
weight placed on the regularization term.
This will depend substantially on the problem, and it should always be
tuned. For many problems, it is reasonable to use no regularization.
If using a non-zero value, we recommend a small value like 0.001.
|
name
|
name prefix for ops created by this function
|
Returns |
[b, m, k] float Tensor of query values. We use train_points and
train_values to perform polyharmonic interpolation. The query values are
the values of the interpolant evaluated at the locations specified in
query_points.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-05-25 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-05-25 UTC."],[],[],null,["# tfa.image.interpolate_spline\n\n|------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/addons/blob/v0.20.0/tensorflow_addons/image/interpolate_spline.py#L237-L315) |\n\nInterpolate signal using polyharmonic interpolation. \n\n tfa.image.interpolate_spline(\n train_points: ../../tfa/types/TensorLike,\n train_values: ../../tfa/types/TensorLike,\n query_points: ../../tfa/types/TensorLike,\n order: int,\n regularization_weight: ../../tfa/types/FloatTensorLike = 0.0,\n name: str = 'interpolate_spline'\n ) -\u003e tf.Tensor\n\nThe interpolant has the form\n\n\\\\\\[f(x) = \\\\sum_{i = 1}\\^n w_i \\\\phi(\\|\\|x - c_i\\|\\|) + v\\^T x + b.\\\\\\]\n\nThis is a sum of two terms: (1) a weighted sum of radial basis function\n(RBF) terms, with the centers \\\\(c_1, ... c_n\\\\), and (2) a linear term\nwith a bias. The \\\\(c_i\\\\) vectors are 'training' points.\nIn the code, b is absorbed into v\nby appending 1 as a final dimension to x. The coefficients w and v are\nestimated such that the interpolant exactly fits the value of the function\nat the \\\\(c_i\\\\) points, the vector w is orthogonal to each \\\\(c_i\\\\),\nand the vector w sums to 0. With these constraints, the coefficients\ncan be obtained by solving a linear system.\n\n\\\\(\\\\phi\\\\) is an RBF, parametrized by an interpolation\norder. Using order=2 produces the well-known thin-plate spline.\n\nWe also provide the option to perform regularized interpolation. Here, the\ninterpolant is selected to trade off between the squared loss on the\ntraining data and a certain measure of its curvature\n([details](https://en.wikipedia.org/wiki/Polyharmonic_spline)).\nUsing a regularization weight greater than zero has the effect that the\ninterpolant will no longer exactly fit the training data. However, it may\nbe less vulnerable to overfitting, particularly for high-order\ninterpolation.\n\nNote the interpolation procedure is differentiable with respect to all\ninputs besides the order parameter.\n\nWe support dynamically-shaped inputs, where batch_size, n, and m are None\nat graph construction time. However, d and k must be known.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|-------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `train_points` | `[batch_size, n, d]` float `Tensor` of n d-dimensional locations. These do not need to be regularly-spaced. |\n| `train_values` | `[batch_size, n, k]` float `Tensor` of n c-dimensional values evaluated at train_points. |\n| `query_points` | `[batch_size, m, d]` `Tensor` of m d-dimensional locations where we will output the interpolant's values. |\n| `order` | order of the interpolation. Common values are 1 for \\\\(\\\\phi(r) = r\\\\), 2 for \\\\(\\\\phi(r) = r\\^2 \\* log(r)\\\\) (thin-plate spline), or 3 for \\\\(\\\\phi(r) = r\\^3\\\\). |\n| `regularization_weight` | weight placed on the regularization term. This will depend substantially on the problem, and it should always be tuned. For many problems, it is reasonable to use no regularization. If using a non-zero value, we recommend a small value like 0.001. |\n| `name` | name prefix for ops created by this function |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| `[b, m, k]` float `Tensor` of query values. We use train_points and train_values to perform polyharmonic interpolation. The query values are the values of the interpolant evaluated at the locations specified in query_points. ||\n\n\u003cbr /\u003e"]]