QDpy
Loading...
Searching...
No Matches
qdpy.algorithms.qdhf.TripletProjector Class Reference

Learn a linear map using a squared-Euclidean triplet margin. More...

Inheritance diagram for qdpy.algorithms.qdhf.TripletProjector:
qdpy.algorithms.divhf.DivHFProjector

Public Member Functions

 fit (self, raw_features, triplets, *, steps=128, batch_size=32, learning_rate=0.01, seed=0)
 Fit or fine-tune the map using an array of labelled indices.
 transform (self, raw_features)
 Apply the same projection to one vector or a matrix of row vectors.

Detailed Description

Learn a linear map using a squared-Euclidean triplet margin.

Project fixed-width raw features into a lower-dimensional space.

For each labelled triplet, fit a linear map so the anchor is closer
to the preferred point than to the other point by at least the margin.
Distances in the training loss are squared Euclidean distances.

:param raw_feature_size: Number of input coordinates after feature extraction.
:param descriptor_size: Number of learned descriptor coordinates.
:param margin: Positive target gap between squared distances.
:param seed: Seed for the initial projection.

Definition at line 24 of file qdhf.py.

Member Function Documentation

◆ fit()

qdpy.algorithms.qdhf.TripletProjector.fit ( self,
raw_features,
triplets,
* ,
steps = 128,
batch_size = 32,
learning_rate = 0.01,
seed = 0 )

Fit or fine-tune the map using an array of labelled indices.

Use Adam on the triplet hinge loss and return the fitted projector.

Each row of ``triplets`` gives three distinct row indices into
``raw_features``: anchor, preferred neighbor, other candidate.
Training starts with the current projection and independent Adam
moments. Commit the updated weights only after a finite fit.

Reimplemented in qdpy.algorithms.divhf.DivHFProjector.

Definition at line 54 of file qdhf.py.

◆ transform()

qdpy.algorithms.qdhf.TripletProjector.transform ( self,
raw_features )

Apply the same projection to one vector or a matrix of row vectors.

Return descriptor coordinates in the units of the trained projection.

Definition at line 99 of file qdhf.py.


The documentation for this class was generated from the following file: