Interpolate
Interpolate
Bases: JSONSerializable
Interpolate
combines a set of Outputs
weighted by dissimilarity scores.
The scores depend on the Metric
used by the NNSearch
.
They may be, for example, distances or negative cosine similarities.
Source code in src/anguilla/interpolate.py
__call__(targets, scores)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
targets |
List[Output]
|
[k x ...batch dims... x output ] first dimension is neighbor dimension trailing dimensions are feature dimensions remaining dimensions are batch dimensions |
required |
scores |
Scores
|
[k x ...batch dims...] |
required |
Returns:
Name | Type | Description |
---|---|---|
output |
Output
|
[ |
Source code in src/anguilla/interpolate.py
Mean
Bases: Interpolate
mean of neighbors (piecewise constant mapping)
Source code in src/anguilla/interpolate.py
Nearest
Bases: Interpolate
return nearest neighbor (voronoi cell mapping)
NOTE: preferable to use Mean
with k=1
in most cases.
Source code in src/anguilla/interpolate.py
Ripple
Bases: Interpolate
like Smooth
but with high-frequency ripples outside the input domain.
useful for making random mappings in high dimensional spaces / bootstrapping expressive mappings from a few points.
Equivalent to Nearest
if used with k < 3
Scale-equivariant; the scale of inputs interacts with the ripple
frequency.
If input data is scaled by a factor s
, scale ripple
by 1/s
to compensate.
Source code in src/anguilla/interpolate.py
__call__(targets, scores, ripple=1, ripple_depth=1, eps=1e-06)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
targets |
List[Output]
|
size [K x ...output_dims...] list or ndarray |
required |
scores |
List[float]
|
size [K] list or ndarray |
required |
ripple |
float
|
frequency of ripples |
1
|
ripple_depth |
float
|
amplitude of ripples |
1
|
eps |
float
|
small value preventing division by zero |
1e-06
|
Source code in src/anguilla/interpolate.py
Smooth
Bases: Interpolate
Interpolate which tries to prevent discontinuities while preserving the input-output mapping exactly where close to data points.
Only works for k > 2
, and generally works well with larger k
.
out-of-domain input areas tend to be averages of many outputs.
Equivalent to Nearest
if used with k < 3
.
Scale-invariant, should work the same if inputs are rescaled. (still recommended to keep inputs roughly normalized for numerical stability)
Source code in src/anguilla/interpolate.py
__call__(targets, scores, eps=1e-06)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
targets |
List[Output]
|
size [K, ...batch dims..., output dim] |
required |
scores |
List[float]
|
size [K, ...batch dims...] |
required |
eps |
float
|
small value preventing division by zero |
1e-06
|
Source code in src/anguilla/interpolate.py
Softmax
Bases: Interpolate
Like Mean
, but weighted toward the nearer neighbors.
when k
is small, has discontinuities
when temp is large, acts more like Mean
.
-> tends to get 'washed out' for larger k
/ larger temp
when temp is small, acts more like Nearest
(voronoi cells).
Scale-equivariant; the scale of inputs interacts with the temp
parameter.
If input data is scaled by a factor s
, scale temp
by s
to compensate.
Source code in src/anguilla/interpolate.py
__call__(targets, scores, temp=0.25)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
targets |
List[Output]
|
size [K x ...batch dims... x ...output_dims...] |
required |
scores |
List[float]
|
size [K x ...batch dims...] |
required |
temp |
float
|
temperature of softmax |
0.25
|