This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def triplet_loss_soft(anchor, positive, negative, m=1): | |
"""Calculate the triplet loss according to the FaceNet paper | |
Args: | |
anchor: the embeddings for the anchor images. | |
positive: the embeddings for the positive images. | |
negative: the embeddings for the negative images. | |
Returns: | |
the triplet loss according to the FaceNet paper as a float tensor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def triplet_loss(anchor, positive, negative, alpha): | |
"""Calculate the triplet loss according to the FaceNet paper | |
Args: | |
anchor: the embeddings for the anchor images. | |
positive: the embeddings for the positive images. | |
negative: the embeddings for the negative images. | |
Returns: | |
the triplet loss according to the FaceNet paper as a float tensor. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
layer { | |
name: "train-data" | |
type: "Data" | |
top: "data" | |
top: "label" | |
include { | |
phase: TRAIN | |
} | |
transform_param { | |
mirror: true |
OlderNewer