semvec/pypi-packages huggingface dataset:
TripletTorch 0.1.3
Triplet Loss Utils for Pytorch Library.
License: MIT
Requires Python: >=3.4, <4


Triplet Loss Utility for Pytorch Library.

# TripletTorch

TripletTorch is a small pytorch utility for triplet loss projects. It provides
simple way to create custom triplet datasets and common triplet mining loss
techniques.

## Install

Install the module using the pip utility ( may require to run as sudo ).

```bash
pip3 install triplettorch
```

## Usage

### Triplet Dataset

```python
from triplettorch import TripletDataset

# Create a triplet dataset given:
#   * labels  : array of label ( class ) for each sample of the dataset
#   * data_fn : method to access data for a given index in the dataset
#   * size    : number of samples in the dataset
#   * n_sample: number of sample per draw ( to increase probability to
#               contain valid triplets in a batch )
# Do not forget to concatenate batch dimension and sample dimension
# when used with a DataLoader as TripletDataset[ idx ] returns a
# ( batch_size, n_sample, ... ) dimension tensor for labels and data
dataset = TripletDataset( labels, data_fn, size, n_sample )
```

### Triplet Mining

```python
from triplettorch import AllTripletMiner, HardNegativeTripletMiner

# Define the triplet mining loss given:
#   * margin: the margin float value from the triplet loss definition
miner          = AllTripletMiner( .5 ).cuda( )
miner          = HardNegativeTripletMiner( .5 ).cuda( )

# Use the loss in training given:
#   * labels    : array of label ( class ) for each sample of the batch
#   * embeddings: output of the neural network for each sample of the batch
# Returns two values:
#   * loss    : triplet loss value
#   * frac_pos: fraction of positive triplets
#               None ( None HardNegativeTripletMiner )
loss, frac_pos = miner( labels, embeddings )
```

## Example

The repository provides an example application with the MNIST dataset.

![ MNIST ]( examples/MNIST_AllTripletMiner.png )


## References
* [FaceNet: A Unified Embedding for Face Recognition and Clustering]
* [Triplet Loss and Online Triplet Mining in TensorFlow]

[FaceNet: A Unified Embedding for Face Recognition and Clustering]: https://arxiv.org/pdf/1503.03832.pdf
[Triplet Loss and Online Triplet Mining in TensorFlow]:https://omoindrot.github.io/triplet-loss
pipeline-exec 0.4
A Pipeline to process an Object Collection
License: MIT

# pipeline-exec

## About
pipeline-exec is an execution Pipeline to apply to  an Object Collection. It's like a
group of functions to run on a list of objects.
The original goal behind this project was to create a framework to help create a funnel pipeline for Django models instance.
We're sure there can be many more uses.

## Installation
Just run:
```
  pip install -U pipeline-exec
```

## Usage
You need to create a pipeline and add a few funnels to it:

```python
from pipeline_exec.pipeline import Pipe, Pipeline

# creating our funnels
class MyTestPipePlusOne(Pipe):
    def run(self, l):
        return [i + 1 for i in l]


class MyTestPipePlusTwo(Pipe):
    def run(self, l):
        return [i + 2 for i in l]


class MyTestPipeMinusOne(Pipe):
    def run(self, l):
        return [i - 1 for i in l]

# creating our pipeline
pipeline = Pipeline([MyTestPipePlusOne(), MyTestPipePlusTwo(), MyTestPipeMinusOne()])

# run the pipeline
pipeline.run([1, 1, 1]) # returns [3, 3, 3]
```

## Contribute
For now, it's very straight forward. Everyone is welcome to contribute. All pull request are against the develop branch.
Unit tests and the flake8 linter run at every push.
Thanks in advance for your contribution :)