Embed
Cat
Bases: Embedding
Embedding which applies multiple other embeddings to elements of a sequence, and concatenates the results
Source code in src/anguilla/embed.py
Chain
Bases: Embedding
Embedding which applies multiple embeddings in series to the same input
Source code in src/anguilla/embed.py
Identity
Bases: Embedding
The most basic Embedding. Optionally checks size of input vector and ensures it is a numpy array, but otherwise leaves it unchanged.
Source code in src/anguilla/embed.py
__call__(source)
embed the input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
an input sequence |
required |
Returns:
Name | Type | Description |
---|---|---|
feature |
ArrayLike
|
the input sequence as a numpy array. |
Source code in src/anguilla/embed.py
__init__(size=None)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
size |
Optional[int]
|
both the Input and the Feature size. if supplied, inputs will be validated to be that size. otherwise, they will just be converted to ndarrays. |
None
|
Source code in src/anguilla/embed.py
ProjectAndSort
Bases: Embedding
Embedding for point cloud-like data.
use with an L2 distance Metric
to compute sliced optimal transport.
if an Input is a 2D array [B x C], B being the point dimension (order not meaningful) and C being the coordinate dimension (order meaningful)
e.g. [ [x0,y0,z0], [x1,y1,z1], [x2,y2,z2], [x3,y3,z3], ] would be a cloud of B=4 points in C=3 dimensional space
This computes n
pseudo-random projections down to 1-dimensional spaces,
sorts along those lines,
and then concatenates to make one feature vector.
the L2 distance between feature vectors is the sliced OT distance between point clouds.
Source code in src/anguilla/embed.py
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
|
__call__(source)
embed the input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
an 2d input sequence of shape [batch x coordinates] |
required |
Returns:
Name | Type | Description |
---|---|---|
feature |
ArrayLike
|
1d array of concatenated projections of the input points. |
Source code in src/anguilla/embed.py
__init__(input_size=None, n=16, seed=0)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
input_size |
Tuple[int, int]
|
input shape [B,C]; if None, lazy init on first call |
None
|
n |
int
|
number of random projections. |
16
|
seed |
int
|
random seed. |
0
|
Source code in src/anguilla/embed.py
Random
Bases: Embedding
Pseudo-random uniform embedding in [-1, 1] for any hashable inputs.
Source code in src/anguilla/embed.py
__call__(source)
embed the input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
a hashable input. cannot be batched. |
required |
Returns:
Name | Type | Description |
---|---|---|
feature |
ArrayLike
|
uniformly distributed pseudo-random vector |
Source code in src/anguilla/embed.py
RandomNormal
Bases: Embedding
Pseudo-random Gaussian embedding for any hashable inputs.
Source code in src/anguilla/embed.py
__call__(source)
embed the input.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source |
an input sequence |
required |
Returns:
Name | Type | Description |
---|---|---|
feature |
ArrayLike
|
normally distributed pseudo-random vector |