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 |
required |
scores |
Scores
|
[k] |
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)
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.
Source code in src/anguilla/interpolate.py
__call__(targets, scores, ripple=1, ripple_depth=1, eps=1e-09)
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-09
|
Source code in src/anguilla/interpolate.py
Smooth
Bases: Interpolate
Interpolate which is non-discontinuous (for k
> 2)
tries to prevent discontinuities while preserving the input-output mapping exactly where close to data points.
works well with larger k
.
out-of-domain input areas tend to be averages of many outputs.
Source code in src/anguilla/interpolate.py
__call__(targets, scores, eps=1e-09)
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 |
eps |
float
|
small value preventing division by zero |
1e-09
|
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).
Source code in src/anguilla/interpolate.py
__call__(targets, scores, temp=0.5)
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.5
|