name: "CaffeNET"
layers {
  name: "data"
  type: IMAGE_DATA_TRIPLET
  top: "data"
  top: "index1_si"
  top: "index2_si"
  top: "index3_si"
  image_data_pair_param {
    source: "../dataset"
    img_files: "../filelist/trainlist.txt"
    cropsize:1
    cropsize_h:160
    cropsize_w:60
    class_per_iter:60
    triplet_per_class:80
    batch_iter:1
    img_counts_per_class_per_iter:2
    mirror: false
    scale: 1
  }
  include: { phase: TRAIN }
}


layers {
  name: "data1"
  type: DATA
  top: "mdata1"
  top: "label1"
  data_param {
    source: "../filelist/triplet/val_triplet1_180x80_lmdb"
    backend: LMDB
    batch_size: 500
  }
  transform_param {
    mirror: false
  }
  include: { phase: TEST }
}

layers {
  name: "data2"
  type: DATA
  top: "mdata2"
  top: "label2"
  data_param {
    source: "../filelist/triplet/val_triplet2_180x80_lmdb"
    backend: LMDB
    batch_size: 500
  }
  transform_param {
    mirror: false
  }
  include: { phase: TEST }
}

layers {
  name: "data3"
  type: DATA
  top: "mdata3"
  top: "label3"
  data_param {
    source: "../filelist/triplet/val_triplet3_180x80_lmdb"
    backend: LMDB
    batch_size: 500
  }
  transform_param {
    mirror: false
  }
  include: { phase: TEST }
}

layers {
  name: "transform1"
  type: IMAGE_TEST_TRANSFORM
  bottom: "mdata1"
  top: "data1"
  image_data_pair_param {
    cropsize:1
    cropsize_h:160
    cropsize_w:60
    scale: 1
  }
  include: { phase: TEST }
}



layers {
  name: "transform2"
  type: IMAGE_TEST_TRANSFORM
  bottom: "mdata2"
  top: "data2"
  image_data_pair_param {
    cropsize:1
    cropsize_h:160
    cropsize_w:60
    scale: 1
  }
  include: { phase: TEST }
}

layers {
  name: "transform3"
  type: IMAGE_TEST_TRANSFORM
  bottom: "mdata3"
  top: "data3"
  image_data_pair_param {
    cropsize:1
    cropsize_h:160
    cropsize_w:60
    scale: 1
  }
  include: { phase: TEST }
}


layers {
  name: "randci"
  type: RAND_SELECT
  bottom: "index1_si"
  bottom: "index2_si"
  bottom: "index3_si"
  top: "index1_ci"
  top: "index2_ci"
  top: "index3_ci"
  rand_select_param {
    batchsize: 100
  }
  include: { phase: TRAIN }
}

layers {
  name: "pairdata_data"
  type: PAIR_DATA
  bottom: "index1_ci"
  bottom: "index2_ci"
  bottom: "index3_ci"
  bottom: "data"
  top: "data1"
  top: "data2"
  top: "data3"
  include: { phase: TRAIN }
}





layers {
  name: "conv11"
  type: CONVOLUTION
  bottom: "data"
  top: "conv11"
  blobs_lr: 1
  blobs_lr: 2
  weight_decay: 0
  weight_decay: 0
  convolution_param {
    num_output: 32
    kernel_size: 5
    pad: 0
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
  include: { phase: TRAIN }
}

layers {
  name: "relu11"
  type: RELU
  bottom: "conv11"
  top: "conv11"
  include: { phase: TRAIN }
}


layers {
  name: "conv11"
  type: CONVOLUTION
  bottom: "data1"
  bottom: "data2"
  bottom: "data3"
  top: "conv11_1"
  top: "conv11_2"
  top: "conv11_3"
  blobs_lr: 1
  blobs_lr: 2
  weight_decay: 0
  weight_decay: 0
  convolution_param {
    num_output: 32
    kernel_size: 5
    pad: 0
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
  include: { phase: TEST }
}

layers {
  name: "relu11_1"
  type: RELU
  bottom: "conv11_1"
  top: "conv11_1"
  include: { phase: TEST }
}

layers {
  name: "relu11_2"
  type: RELU
  bottom: "conv11_2"
  top: "conv11_2"
  include: { phase: TEST }
}

layers {
  name: "relu11_3"
  type: RELU
  bottom: "conv11_3"
  top: "conv11_3"
  include: { phase: TEST }
}



layers {
  name: "pool1"
  type: POOLING
  bottom: "conv11"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 3
  }
  include: { phase: TRAIN }
}

layers {
  name: "pool1_1"
  type: POOLING
  bottom: "conv11_1"
  top: "pool1_1"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 3
  }
  include: { phase: TEST }
}

layers {
  name: "pool1_2"
  type: POOLING
  bottom: "conv11_2"
  top: "pool1_2"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 3
  }
  include: { phase: TEST }
}

layers {
  name: "pool1_3"
  type: POOLING
  bottom: "conv11_3"
  top: "pool1_3"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 3
  }
  include: { phase: TEST }
}


layers {
  name: "pairdata_pool1"
  type: PAIR_DATA
  bottom: "index1_ci"
  bottom: "index2_ci"
  bottom: "index3_ci"
  bottom: "pool1"
  top: "pool1_1"
  top: "pool1_2"
  top: "pool1_3"
  include: { phase: TRAIN }
}



layers {
  name: "conv21"
  type: CONVOLUTION
  bottom: "pool1"
  top: "conv21"
  blobs_lr: 1
  blobs_lr: 2
  weight_decay: 0
  weight_decay: 0
  convolution_param {
    num_output: 64
    kernel_size: 3
    pad: 0
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
  include: { phase: TRAIN }
}

layers {
  name: "relu21"
  type: RELU
  bottom: "conv21"
  top: "conv21"
  include: { phase: TRAIN }
}


layers {
  name: "conv21"
  type: CONVOLUTION
  bottom: "pool1_1"
  bottom: "pool1_2"
  bottom: "pool1_3"
  top: "conv21_1"
  top: "conv21_2"
  top: "conv21_3"
  blobs_lr: 1
  blobs_lr: 2
  weight_decay: 0
  weight_decay: 0
  convolution_param {
    num_output: 64
    kernel_size: 3
    pad: 0
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
  include: { phase: TEST }
}

layers {
  name: "relu21_1"
  type: RELU
  bottom: "conv21_1"
  top: "conv21_1"
  include: { phase: TEST }
}

layers {
  name: "relu21_2"
  type: RELU
  bottom: "conv21_2"
  top: "conv21_2"
  include: { phase: TEST }
}

layers {
  name: "relu21_3"
  type: RELU
  bottom: "conv21_3"
  top: "conv21_3"
  include: { phase: TEST }
}

layers {
  name: "pool2"
  type: POOLING
  bottom: "conv21"
  top: "pool2"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
  include: { phase: TRAIN }
}


layers {
  name: "pool2_1"
  type: POOLING
  bottom: "conv21_1"
  top: "pool2_1"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
  include: { phase: TEST }
}

layers {
  name: "pool2_2"
  type: POOLING
  bottom: "conv21_2"
  top: "pool2_2"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
  include: { phase: TEST }
}

layers {
  name: "pool2_3"
  type: POOLING
  bottom: "conv21_3"
  top: "pool2_3"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
  include: { phase: TEST }
}

layers {
  name: "pairdata_pool2"
  type: PAIR_DATA
  bottom: "index1_ci"
  bottom: "index2_ci"
  bottom: "index3_ci"
  bottom: "pool2"
  top: "pool2_1"
  top: "pool2_2"
  top: "pool2_3"
  include: { phase: TRAIN }
}

layers {
  name: "conc_pool2_12"
  type: CONCAT
  bottom: "pool2_1"
  bottom: "pool2_2"
  top: "conc_pool2_12"
  concat_param {
    concat_dim: 1
  }
}

layers {
  name: "conc_pool2_13"
  type: CONCAT
  bottom: "pool2_1"
  bottom: "pool2_3"
  top: "conc_pool2_13"
  concat_param {
    concat_dim: 1
  }
}

layers {
  name: "conv31"
  type: CONVOLUTION
  bottom: "pool2"
  top: "conv31"
  blobs_lr: 1
  blobs_lr: 2
  weight_decay: 0
  weight_decay: 0
  convolution_param {
    num_output: 32
    kernel_size: 3
    pad: 0
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
  include: { phase: TRAIN }
}

layers {
  name: "relu31"
  type: RELU
  bottom: "conv31"
  top: "conv31"
  include: { phase: TRAIN }
}


layers {
  name: "conv31"
  type: CONVOLUTION
  bottom: "pool2_1"
  bottom: "pool2_2"
  bottom: "pool2_3"
  top: "conv31_1"
  top: "conv31_2"
  top: "conv31_3"
  blobs_lr: 1
  blobs_lr: 2
  weight_decay: 0
  weight_decay: 0
  convolution_param {
    num_output: 32
    kernel_size: 3
    pad: 0
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
  include: { phase: TEST }
}

layers {
  name: "relu31_1"
  type: RELU
  bottom: "conv31_1"
  top: "conv31_1"
  include: { phase: TEST }
}

layers {
  name: "relu31_2"
  type: RELU
  bottom: "conv31_2"
  top: "conv31_2"
  include: { phase: TEST }
}

layers {
  name: "relu31_3"
  type: RELU
  bottom: "conv31_3"
  top: "conv31_3"
  include: { phase: TEST }
}

layers {
  name: "conv31b"
  type: CONVOLUTION
  bottom: "conc_pool2_12"
  bottom: "conc_pool2_13"
  top: "conv3b_12"
  top: "conv3b_13"
  blobs_lr: 1
  blobs_lr: 2
  weight_decay: 0
  weight_decay: 0
  convolution_param {
    num_output: 32
    kernel_size: 3
    pad: 0
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
      value: 0
    }
  }
}

layers {
  name: "relu31b_12"
  type: RELU
  bottom: "conv3b_12"
  top: "conv3b_12"
}

layers {
  name: "relu31b_13"
  type: RELU
  bottom: "conv3b_13"
  top: "conv3b_13"
}

layers {
  name: "pool3"
  type: POOLING
  bottom: "conv31"
  top: "pool3"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
  include: { phase: TRAIN }
}

layers {
  name: "pairdata_pool3"
  type: PAIR_DATA
  bottom: "index1_ci"
  bottom: "index2_ci"
  bottom: "index3_ci"
  bottom: "pool3"
  top: "pool3_1"
  top: "pool3_2"
  top: "pool3_3"
  include: { phase: TRAIN }
}

layers {
  name: "pool3_1"
  type: POOLING
  bottom: "conv31_1"
  top: "pool3_1"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
  include: { phase: TEST }
}

layers {
  name: "pool3_2"
  type: POOLING
  bottom: "conv31_2"
  top: "pool3_2"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
  include: { phase: TEST }
}

layers {
  name: "pool3_3"
  type: POOLING
  bottom: "conv31_3"
  top: "pool3_3"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
  include: { phase: TEST }
}



layers {
  name: "pool3b_12"
  type: POOLING
  bottom: "conv3b_12"
  top: "pool3b_12"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}

layers {
  name: "pool3b_13"
  type: POOLING
  bottom: "conv3b_13"
  top: "pool3b_13"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}

layers {
  name: "conc_pool3_12"
  type: CONCAT
  bottom: "pool3_1"
  bottom: "pool3b_12"
  bottom: "pool3_2"
  top: "conc_pool3_12"
  concat_param {
    concat_dim: 1
  }
}

layers {
  name: "conc_pool3_13"
  type: CONCAT
  bottom: "pool3_1"
  bottom: "pool3b_13"
  bottom: "pool3_3"
  top: "conc_pool3_13"
  concat_param {
    concat_dim: 1
  }
}

layers {
  name: "drop1"
  type: DROPOUT
  bottom: "pool3"
  top: "drop1"
  dropout_param {
    dropout_ratio: 0.4
  }
  include: { phase: TRAIN }
}

layers {
  name: "drop1_1"
  type: DROPOUT
  bottom: "pool3_1"
  top: "drop1_1"
  dropout_param {
    dropout_ratio: 0.4
  }
  include: { phase: TEST }
}

layers {
  name: "drop1_2"
  type: DROPOUT
  bottom: "pool3_2"
  top: "drop1_2"
  dropout_param {
    dropout_ratio: 0.4
  }
  include: { phase: TEST }
}

layers {
  name: "drop1_3"
  type: DROPOUT
  bottom: "pool3_3"
  top: "drop1_3"
  dropout_param {
    dropout_ratio: 0.4
  }
  include: { phase: TEST }
}

layers {
  name: "dropb_12"
  type: DROPOUT
  bottom: "pool3b_12"#"conc_pool3_12"
  top: "dropb_12"
  dropout_param {
    dropout_ratio: 0
  }
}

layers {
  name: "dropb_13"
  type: DROPOUT
  bottom: "pool3b_13"#"conc_pool3_13"
  top: "dropb_13"
  dropout_param {
    dropout_ratio: 0
  }
}

layers {
  name: "fc1"
  type: INNER_PRODUCT
  bottom: "drop1"
  top: "fc1"
  blobs_lr: 1
  blobs_lr: 2
  weight_decay: 10
  weight_decay: 0
  inner_product_param {
    num_output: 1000
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
      value: 1
    }
  }
  include: { phase: TRAIN }
}

layers {
  name: "relu3"
  type: RELU
  bottom: "fc1"
  top: "fc1"
  include: { phase: TRAIN }
}

layers {
  name: "fc1"
  type: INNER_PRODUCT
  bottom: "drop1_1"
  bottom: "drop1_2"
  bottom: "drop1_3"
  top: "fc1_1"
  top: "fc1_2"
  top: "fc1_3"
  blobs_lr: 1
  blobs_lr: 2
  weight_decay: 10
  weight_decay: 0
  inner_product_param {
    num_output: 1000
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
      value: 1
    }
  }
  include: { phase: TEST }
}



layers {
  name: "relu3_1"
  type: RELU
  bottom: "fc1_1"
  top: "fc1_1"
  include: { phase: TEST }
}

layers {
  name: "relu3_2"
  type: RELU
  bottom: "fc1_2"
  top: "fc1_2"
  include: { phase: TEST }
}

layers {
  name: "relu3_3"
  type: RELU
  bottom: "fc1_3"
  top: "fc1_3"
  include: { phase: TEST }
}

layers {
  name: "fc1_b"
  type: INNER_PRODUCT
  bottom: "dropb_12"
  bottom: "dropb_13"
  top: "fc1b_12"
  top: "fc1b_13"
  blobs_lr: 1
  blobs_lr: 2
  weight_decay: 10
  weight_decay: 0
  inner_product_param {
    num_output: 1000
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
      value: 1
    }
  }
}

layers {
  name: "relu3b_12"
  type: RELU
  bottom: "fc1b_12"
  top: "fc1b_12"
}

layers {
  name: "relu3b_13"
  type: RELU
  bottom: "fc1b_13"
  top: "fc1b_13"
}

layers {
  name: "drop2"
  type: DROPOUT
  bottom: "fc1"
  top: "drop2"
  dropout_param {
    dropout_ratio: 0
  }
  include: { phase: TRAIN }
}

layers {
  name: "drop2_1"
  type: DROPOUT
  bottom: "fc1_1"
  top: "drop2_1"
  dropout_param {
    dropout_ratio: 0
  }
  include: { phase: TEST }
}

layers {
  name: "drop2_2"
  type: DROPOUT
  bottom: "fc1_2"
  top: "drop2_2"
  dropout_param {
    dropout_ratio: 0
  }
  include: { phase: TEST }
}

layers {
  name: "drop2_3"
  type: DROPOUT
  bottom: "fc1_3"
  top: "drop2_3"
  dropout_param {
    dropout_ratio: 0
  }
  include: { phase: TEST }
}

layers {
  name: "drop2b_12"
  type: DROPOUT
  bottom: "fc1b_12"
  top: "drop2b_12"
  dropout_param {
    dropout_ratio: 0
  }
}

layers {
  name: "drop2b_13"
  type: DROPOUT
  bottom: "fc1b_13"
  top: "drop2b_13"
  dropout_param {
    dropout_ratio: 0
  }
}

layers {
  name: "fc2"
  type: INNER_PRODUCT
  bottom: "drop2"
  top: "fc2"
  blobs_lr: 1
  weight_decay: 10
  inner_product_param {
    num_output: 500
    bias_term: false
    weight_filler {
      type: "xavier"
    }
  }
  include: { phase: TRAIN }
}


layers {
  name: "fc2"
  type: INNER_PRODUCT
  bottom: "drop2_1"
  bottom: "drop2_2"
  bottom: "drop2_3"
  top: "fc2_1"
  top: "fc2_2"
  top: "fc2_3"
  blobs_lr: 1
  weight_decay: 10
  inner_product_param {
    num_output: 500
    bias_term: false
    weight_filler {
      type: "xavier"
    }
  }
  include: { phase: TEST }
}








layers {
  name: "fc3b"
  type: INNER_PRODUCT
  bottom: "drop2b_12"
  bottom: "drop2b_13"
  top: "fc3b_12"
  top: "fc3b_13"
  blobs_lr: 1
  blobs_lr: 2
  weight_decay: 10
  weight_decay: 0
  inner_product_param {
    num_output: 1
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
      value: 1
    }
  }
}


layers {
  name: "flat_fc"
  type: FLATTEN
  bottom: "fc2"
  top: "flat_fc"
  include: { phase: TRAIN }
}


layers {
  name: "flat_fc1"
  type: FLATTEN
  bottom: "fc2_1"
  top: "flat_fc1"
  include: { phase: TEST }
}

layers {
  name: "flat_fc2"
  type: FLATTEN
  bottom: "fc2_2"
  top: "flat_fc2"
  include: { phase: TEST }
}

layers {
  name: "flat_fc3"
  type: FLATTEN
  bottom: "fc2_3"
  top: "flat_fc3"
  include: { phase: TEST }
}

layers {
  name: "pairdata_flatfc"
  type: PAIR_DATA
  bottom: "index1_si"
  bottom: "index2_si"
  bottom: "index3_si"
  bottom: "flat_fc"
  top: "flat_fc1"
  top: "flat_fc2"
  top: "flat_fc3"
  include: { phase: TRAIN }
}

layers {
  name: "cost3"
  type: TRIPLET_LOSS
  bottom: "flat_fc1"
  bottom: "flat_fc2"
  bottom: "flat_fc3"
  top: "loss3"
  loss_weight: 1
  contrastive_loss_param {
    margin: 10
  }
}

#layers {
#  name: "cost3"
#  type: DOUBLET_LOSS
#  bottom: "flat_fc1"
#  bottom: "flat_fc2"
#  bottom: "pairlabel"
#  top: "loss3"
#  blobs_lr: 0
#  loss_weight: 1
#  doublet_loss_param {
#    margin: 0
#    bias_term: true
#    bias_filler {
#      type: "constant"
#      value: 3
#    }
#  }
#}

layers {
  name: "cost4"
  type: LINEAR_TRIPLET_LOSS
  bottom: "fc3b_12"
  bottom: "fc3b_13"
  top: "loss4"
  loss_weight: 1
  contrastive_loss_param {
    margin: 10
  }
}



