finetuner.tuner.keras.miner module

class finetuner.tuner.keras.miner.SiameseMiner(*args, **kwds)[source]

Bases: finetuner.tuner.miner.base.BaseClassMiner[tensorflow.Tensor]

mine(labels, distances)[source]

Generate all possible pairs.

Parameters
  • labels (Tensor) – A 1D tensor of item labels (classes)

  • distances (Tensor) – A tensor matrix of pairwise distance between each two item embeddings

Return type

Tuple[Tensor, Tensor, Tensor]

Returns

three 1D tensors, first one holding integers of first element of pair, second of the second element of pair, and third one the label (0 or 1) for the pair for each pair

class finetuner.tuner.keras.miner.TripletMiner(*args, **kwds)[source]

Bases: finetuner.tuner.miner.base.BaseClassMiner[tensorflow.Tensor]

mine(labels, distances)[source]

Generate all possible triplets.

Parameters
  • labels (Tensor) – A 1D tensor of item labels (classes)

  • distances (Tensor) – A tensor matrix of pairwise distance between each two item embeddings

Return type

Tuple[Tensor, Tensor, Tensor]

Returns

three 1D tensors, holding the anchor index, positive index and negative index of each triplet, respectively

class finetuner.tuner.keras.miner.SiameseSessionMiner(*args, **kwds)[source]

Bases: finetuner.tuner.miner.base.BaseSessionMiner[tensorflow.Tensor]

mine(labels, distances)[source]

Generate all possible pairs for each session.

Parameters
  • labels (Tuple[Tensor, Tensor]) – A tuple of 1D tensors, denotind the items’ session and match type (0 for anchor, 1 for postive match and -1 for negative match), respectively

  • distances (Tensor) – A tensor matrix of pairwise distance between each two item embeddings

Return type

Tuple[Tensor, Tensor, Tensor]

Returns

three numpy arrays, first one holding integers of first element of pair, second of the second element of pair, and third one the label (0 or 1) for the pair for each pair

class finetuner.tuner.keras.miner.TripletSessionMiner(*args, **kwds)[source]

Bases: finetuner.tuner.miner.base.BaseSessionMiner[tensorflow.Tensor]

mine(labels, distances)[source]

Generate all possible triplets for each session.

Parameters
  • labels (Tuple[Tensor, Tensor]) – A tuple of 1D tensors, denotind the items’ session and match type (0 for anchor, 1 for postive match and -1 for negative match), respectively

  • distances (Tensor) – A tensor matrix of pairwise distance between each two item embeddings

Return type

Tuple[Tensor, Tensor, Tensor]

Returns

three numpy arrays, holding the anchor index, positive index and negative index of each triplet, respectively