改进mnist siamese网络,使用concat和全连接+software替换掉 对比loss function 。编写caffe 的网络,出现的问题

I0125 20:44:48.127285 38353 solver.cpp:87] Creating training net from net file: examples/siamese/mnist_matchNet_train_test.prototxt
[libprotobuf ERROR google/protobuf/text_format.cc:274] Error parsing text-format caffe.NetParameter: 462:1: Expected identifier.
F0125 20:44:48.127604 38353 upgrade_proto.cpp:88] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: examples/siamese/mnist_matchNet_train_test.prototxt
*** Check failure stack trace: ***
    @     0x7faba82fa5cd  google::LogMessage::Fail()
    @     0x7faba82fc433  google::LogMessage::SendToLog()
    @     0x7faba82fa15b  google::LogMessage::Flush()
    @     0x7faba82fce1e  google::LogMessageFatal::~LogMessageFatal()
    @     0x7faba8ab4431  caffe::ReadNetParamsFromTextFileOrDie()
    @     0x7faba8a611bc  caffe::Solver<>::InitTrainNet()
    @     0x7faba8a624e5  caffe::Solver<>::Init()
    @     0x7faba8a627ff  caffe::Solver<>::Solver()
    @     0x7faba8a7f711  caffe::Creator_SGDSolver<>()
    @           0x40a9e8  train()
    @           0x4072e0  main
    @     0x7faba726a830  __libc_start_main
    @           0x407b09  _start
    @              (nil)  (unknown)
./examples/siamese/train_mnist_matchNet.sh: line 5: 38353 Aborted                 (core dumped) $TOOLS/caffe train --solver=examples/siamese/mnist_matchNet_solver.prototxt $@

网路的框架是:
name: "mnist_matchnet_train_test"
##数据输入
layer {
name: "pair_data"
type: "Data"
top: "pair_data"
top: "sim"
include {
phase: TRAIN
}
transform_param {
scale: 0.00390625
}
data_param {
source: "examples/siamese/mnist_siamese_train_leveldb"
batch_size: 64
}
}
layer {
name: "pair_data"
type: "Data"
top: "pair_data"
top: "sim"
include {
phase: TEST
}
transform_param {
scale: 0.00390625
}
data_param {
source: "examples/siamese/mnist_siamese_test_leveldb"
batch_size: 100
}
}

layer {
name: "slice_pair"
type: "Slice"
bottom: "pair_data"
top: "data"
top: "data_p"
slice_param {
slice_dim: 1
slice_point: 1
}
}
###########卷积层########
layer {
name: "conv1"
type: "Convolution"
bottom: "data"
top: "conv1"
param { ##权重和偏置
name: "conv1_w"
lr_mult: 1
}
param {
name: "conv1_b"
lr_mult: 2
}
convolution_param { ## 输出通道,kernel,stride
num_output: 20
kernel_size: 5
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}
layer {
name: "pool1"
type: "Pooling"
bottom: "conv1"
top: "pool1"
pooling_param {
pool: MAX
kernel_size: 1
stride: 1
}
}
layer {
name: "conv2"
type: "Convolution"
bottom: "pool1"
top: "conv2"
param {
name: "conv2_w"
lr_mult: 1
}
param {
name: "conv2_b"
lr_mult: 2
}
convolution_param {
num_output: 50
kernel_size: 5
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}
layer {
name: "pool2"
type: "Pooling"
bottom: "conv2"
top: "pool2"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}

layer {
name: "conv3"
type: "Convolution"
bottom: "pool2"
top: "conv3"
param {
name: "conv3_w"
lr_mult: 1
}
param {
name: "conv3_b"
lr_mult: 2
}
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}

layer {
name: "conv4"
type: "Convolution"
bottom: "conv3"
top: "conv4"
param {
name: "conv4_w"
lr_mult: 1
}
param {
name: "conv4_b"
lr_mult: 2
}
convolution_param {
num_output:64
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}

layer {
name: "conv5"
type: "Convolution"
bottom: "conv4"
top: "conv5"
param {
name: "conv5_w"
lr_mult: 1
}
param {
name: "conv5_b"
lr_mult: 2
}
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}

layer {
name: "pool3"
type: "Pooling"
bottom: "conv5"
top: "pool3"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}


layer {
name: "ip1"
type: "InnerProduct"
bottom: "pool3"
top: "ip1"
param {
name: "ip1_w"
lr_mult: 1
}
param {
name: "ip1_b"
lr_mult: 2
}
inner_product_param {
num_output: 500
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}

#layer {
# name: "feat"
# type: "InnerProduct"
# bottom: "ip2"
# top: "feat"
# param {
# name: "feat_w"
# lr_mult: 1
# }
# param {
# name: "feat_b"
# lr_mult: 2
# }
# inner_product_param {
# num_output: 2
# weight_filler {
# type: "xavier"
# }
# bias_filler {
# type: "constant"
# }
# }
#}

#######################second 分支######################################
layer {
name: "conv1_p"
type: "Convolution"
bottom: "data_p"
top: "conv1_p"
param {
name: "conv1_w"
lr_mult: 1
}
param {
name: "conv1_b"
lr_mult: 2
}
convolution_param {
num_output: 20
kernel_size: 5
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}
layer {
name: "pool1_p"
type: "Pooling"
bottom: "conv1_p"
top: "pool1_p"
pooling_param {
pool: MAX
kernel_size: 1
stride: 1
}
}
layer {
name: "conv2_p"
type: "Convolution"
bottom: "pool1_p"
top: "conv2_p"
param {
name: "conv2_w"
lr_mult: 1
}
param {
name: "conv2_b"
lr_mult: 2
}
convolution_param {
num_output: 50
kernel_size: 5
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}
layer {
name: "pool2_p"
type: "Pooling"
bottom: "conv2_p"
top: "pool2_p"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}

layer {
name: "conv3_p"
type: "Convolution"
bottom: "pool2_p"
top: "conv3_p"
param {
name: "conv3_w"
lr_mult: 1
}
param {
name: "conv3_b"
lr_mult: 2
}
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}

layer {
name: "conv4_p"
type: "Convolution"
bottom: "conv3_p"
top: "conv4_p"
param {
name: "conv4_w"
lr_mult: 1
}
param {
name: "conv4_b"
lr_mult: 2
}
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}

layer {
name: "conv5_p"
type: "Convolution"
bottom: "conv4_p"
top: "conv5_p"
param {
name: "conv5_w"
lr_mult: 1
}
param {
name: "conv5_b"
lr_mult: 2
}
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}

layer {
name: "pool3_p"
type: "Pooling"
bottom: "conv5_p"
top: "pool3_p"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}

layer {
name: "ip1_p"
type: "InnerProduct"
bottom: "pool3_p"
top: "ip1_p"
param {
name: "ip1_w"
lr_mult: 1
}
param {
name: "ip1_b"
lr_mult: 2
}
inner_product_param {
num_output: 500
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}

layer{
name:"concat"
type:"CONCAT"
bottom:"ip1"
bottom:"ip1_p"
top:"concat"
concat_param{axis:1}
}

#layer {
# name: "relu1_p"
# type: "ReLU"
# bottom: "ip1_p"
# top: "ip1_p"
}
layer {
name: "ip2_p"
type: "InnerProduct"
bottom: "concat"
top: "ip2_p"
param {
name: "ip2_w"
lr_mult: 1
}
param {
name: "ip2_b"
lr_mult: 2
}
inner_product_param {
num_output: 10
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}
layer {
name: "relu1"
type: "ReLU"
bottom: "ip2_p"
top: "ip2_p"
}

layer {
name: "feat_p"
type: "InnerProduct"
bottom: "ip2_p"
top: "feat_p"
param {
name: "feat_w"
lr_mult: 1
}
param {
name: "feat_b"
lr_mult: 2
}
inner_product_param {
num_output: 2
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
}
}
}

layer {
name: "accuracy"
type: "Accuracy"
bottom: "ip2_p"
bottom: "sim"
top: "accuracy"
include {
phase: TEST
}
}

layer {
name: "loss"
type: "SoftmaxWithLoss"
bottom: "feat_p"
bottom: "sim"
top: "loss"
}



 
已邀请:

liyan

赞同来自:

这个网络做图像匹配,网络是 siamese网络,分为两部分:feature net (左右两个相同的网络), matric net (判断两个分支的输出是否相似)。

要回复问题请先登录注册