GithubHelp home page GithubHelp logo

goongong / caffe_triplet_multiple_inputs Goto Github PK

View Code? Open in Web Editor NEW

This project forked from yuhanghe01/caffe_triplet_multiple_inputs

0.0 2.0 0.0 8.17 MB

Caffe Framework for Triplet Network Ranking

License: Other

CMake 2.64% Makefile 0.67% C++ 80.22% Cuda 5.63% MATLAB 0.86% M 0.01% Python 8.01% Shell 0.29% Protocol Buffer 1.70%

caffe_triplet_multiple_inputs's Introduction

Caffe Framework with various triplet loss neural network

Build Status License

This is my caffe framework which is initially designed for triplet loss neural network. It contains various useful implementations, including:

  1. create LEVELDB/LMDB for triplet input: anchor/postive/negative. Code in tools/convert_triplet_db_dataset.cpp.
  2. create LEVELDB/LMDB for multiple postive and negative input. Code in tools/convert_multiple_triplet_db_dataset.cpp.
  3. loss layer with multiple postive and negative input. Code in src/caffe/layers/naive_triplet_multiple_loss_layer.cpp.

Create LMDB/LEVELDB file for triple input

To speed up the overall neural network training, it's better to convert input triple images into LMDB/LEVELDB. I provide the relevant code in tools/convert_triplet_db_dataset.cpp, in which each lines consists of anchor positive and negative respectively. An example list is shown below, not that all images should be shown with absolute pathes, separated by SPACE or TAB.

anchor1.png      pos1.png      neg1.png
anchor2.png      pos2.png      neg2.png
...

Create LMDB/LEVELDB file for multiple postives or negatives input

I extend the current triple input restraint to allow multiple postives and negatives input. That is, an anchor image corresponds to multiple postive and negative input. The relevant code is tools/convert_multiple_triplet_db_dataset.cpp, in which each line accordingly consists of anchor image, multiple postive and multiple negatie images, with two extra numbers indicating the the beginning of positive images and negatives images. An example is shown below:

anchor1.png      pos1.png      pos2.png      pos3.png     neg1.png      neg2.png      neg3.png      neg4.png      1      4
...

The loss layer of multiple positive and negative inputs.

I organize all the positive and negative inputs as one blob with the channel number equals to the total number of anchor positive and negative inputs. In the loss layer, I split the anchor positive and negative inputs and process them separately. So the loss layer prototxt should be specified with the length of anchor, positive and negative respectively.

layer {
     name: "triplet_loss"
     type: "NaiveTripletMultipleLoss"
     bottom: "ip2norm"
     top: "loss"
     top: "accuracy"
     multiple_triplet_loss_param{
     margin: 1
     anchor_len: 1
     pos_len: 3
     neg_len: 4
     batch_size: 30
     sim_type: "DotProductSimilarity"
     }
}

If you find this useful, please cite Caffe paper:

@article{jia2014caffe,
  Author = {Jia, Yangqing and Shelhamer, Evan and Donahue, Jeff and Karayev, Sergey and Long, Jonathan and Girshick, Ross and Guadarrama, Sergio and Darrell, Trevor},
  Journal = {arXiv preprint arXiv:1408.5093},
  Title = {Caffe: Convolutional Architecture for Fast Feature Embedding},
  Year = {2014}
}

caffe_triplet_multiple_inputs's People

Contributors

yuhanghe01 avatar

Watchers

James Cloos avatar zch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.