tripletLoss,训练,网络配置

网络定义中的使用类似softmaxlosslayer,最后两层对应修改举例如下:

#======================softmax====================

# layer {

#  name: "fc9"

#  type: "InnerProduct"

#  bottom: "fc7"

#  top: "fc9"

#  param {

#    lr_mult: 1

#  }

#  param {

#    lr_mult: 2

#  }

#  inner_product_param {

#    num_output: 530

#    weight_filler {

#      type: "xavier"

#    }

#  }

# }

# layer {

#  name: "accuracy"

#  type:  "Accuracy"

#  bottom: "fc9"

#  bottom: "labels"

#  top: "accuracy"

#  include: { phase: TEST }

# }

# layer {

#  name: "loss_cls"

#  type: "SoftmaxWithLoss"

#  bottom: "fc9"

#  bottom: "labels"

#  top: "loss_cls"

#  loss_weight: 1

# }

#====================tripletloss==================

layer {

  name: "norm2"

  type: "Norm"

  bottom: "fc7"

  top: "norm2"

}

layer {

  name: "fc9_1"

  type: "InnerProduct"

  bottom: "norm2"

  top: "fc9_1"

  param {

    lr_mult: 1

    decay_mult: 1

  }

  param {

    lr_mult: 0

    decay_mult: 0

  }

  inner_product_param {

    num_output: 128

    weight_filler {

      type: "xavier"

    }

    bias_filler{

      type: "constant"

      value: 0

    }

  }

}

layer {

  name: "tripletsample"

  type: "TripletSample"

  bottom: "fc9_1"

  bottom: "labels"

  top: "anchor"

  top: "positive"

  top: "negative"

  top: "weight"

}

layer {

  name: "tripletloss"

  type: "TripletLoss"

  bottom: "anchor"

  bottom: "positive"

  bottom: "negative"

  bottom: "weight"

  top: "loss"

}

你可能感兴趣的:(tripletLoss,训练,网络配置)