平台:TX2 ,JetPack3.3
最近在使用TensorRT封装27层的ResNet,封装过程中遇到以下问题:
1.网络结构中的Prelu类型的GPU代码实现;
2.在比对网络结构fc5的输出的时候,输出特征参数只有一半是正确,有一般为0;
首先分享一下网络结构的改造:
原始网络结构:
name: "face_res27net"
input: "data"
input_dim: 1
input_dim: 3
input_dim: 128
input_dim: 128
layer {
name: "conv1a"
type: "Convolution"
bottom: "data"
top: "conv1a"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 32
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu1a"
type: "PReLU"
bottom: "conv1a"
top: "conv1a"
}
layer {
name: "conv1b"
type: "Convolution"
bottom: "conv1a"
top: "conv1b"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu1b"
type: "PReLU"
bottom: "conv1b"
top: "conv1b"
}
layer {
name: "pool1b"
type: "Pooling"
bottom: "conv1b"
top: "pool1b"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
layer {
name: "conv2_1"
type: "Convolution"
bottom: "pool1b"
top: "conv2_1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu2_1"
type: "PReLU"
bottom: "conv2_1"
top: "conv2_1"
}
layer {
name: "conv2_2"
type: "Convolution"
bottom: "conv2_1"
top: "conv2_2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu2_2"
type: "PReLU"
bottom: "conv2_2"
top: "conv2_2"
}
layer {
name: "res2_2"
type: "Eltwise"
bottom: "pool1b"
bottom: "conv2_2"
top: "res2_2"
eltwise_param {
operation: 1
}
}
layer {
name: "conv2"
type: "Convolution"
bottom: "res2_2"
top: "conv2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu2"
type: "PReLU"
bottom: "conv2"
top: "conv2"
}
layer {
name: "pool2"
type: "Pooling"
bottom: "conv2"
top: "pool2"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
layer {
name: "conv3_1"
type: "Convolution"
bottom: "pool2"
top: "conv3_1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu3_1"
type: "PReLU"
bottom: "conv3_1"
top: "conv3_1"
}
layer {
name: "conv3_2"
type: "Convolution"
bottom: "conv3_1"
top: "conv3_2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu3_2"
type: "PReLU"
bottom: "conv3_2"
top: "conv3_2"
}
layer {
name: "res3_2"
type: "Eltwise"
bottom: "pool2"
bottom: "conv3_2"
top: "res3_2"
eltwise_param {
operation: 1
}
}
layer {
name: "conv3_3"
type: "Convolution"
bottom: "res3_2"
top: "conv3_3"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu3_3"
type: "PReLU"
bottom: "conv3_3"
top: "conv3_3"
}
layer {
name: "conv3_4"
type: "Convolution"
bottom: "conv3_3"
top: "conv3_4"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu3_4"
type: "PReLU"
bottom: "conv3_4"
top: "conv3_4"
}
layer {
name: "res3_4"
type: "Eltwise"
bottom: "res3_2"
bottom: "conv3_4"
top: "res3_4"
eltwise_param {
operation: 1
}
}
layer {
name: "conv3"
type: "Convolution"
bottom: "res3_4"
top: "conv3"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu3"
type: "PReLU"
bottom: "conv3"
top: "conv3"
}
layer {
name: "pool3"
type: "Pooling"
bottom: "conv3"
top: "pool3"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
layer {
name: "conv4_1"
type: "Convolution"
bottom: "pool3"
top: "conv4_1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_1"
type: "PReLU"
bottom: "conv4_1"
top: "conv4_1"
}
layer {
name: "conv4_2"
type: "Convolution"
bottom: "conv4_1"
top: "conv4_2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_2"
type: "PReLU"
bottom: "conv4_2"
top: "conv4_2"
}
layer {
name: "res4_2"
type: "Eltwise"
bottom: "pool3"
bottom: "conv4_2"
top: "res4_2"
eltwise_param {
operation: 1
}
}
layer {
name: "conv4_3"
type: "Convolution"
bottom: "res4_2"
top: "conv4_3"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_3"
type: "PReLU"
bottom: "conv4_3"
top: "conv4_3"
}
layer {
name: "conv4_4"
type: "Convolution"
bottom: "conv4_3"
top: "conv4_4"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_4"
type: "PReLU"
bottom: "conv4_4"
top: "conv4_4"
}
layer {
name: "res4_4"
type: "Eltwise"
bottom: "res4_2"
bottom: "conv4_4"
top: "res4_4"
eltwise_param {
operation: 1
}
}
layer {
name: "conv4_5"
type: "Convolution"
bottom: "res4_4"
top: "conv4_5"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_5"
type: "PReLU"
bottom: "conv4_5"
top: "conv4_5"
}
layer {
name: "conv4_6"
type: "Convolution"
bottom: "conv4_5"
top: "conv4_6"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_6"
type: "PReLU"
bottom: "conv4_6"
top: "conv4_6"
}
layer {
name: "res4_6"
type: "Eltwise"
bottom: "res4_4"
bottom: "conv4_6"
top: "res4_6"
eltwise_param {
operation: 1
}
}
layer {
name: "conv4_7"
type: "Convolution"
bottom: "res4_6"
top: "conv4_7"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_7"
type: "PReLU"
bottom: "conv4_7"
top: "conv4_7"
}
layer {
name: "conv4_8"
type: "Convolution"
bottom: "conv4_7"
top: "conv4_8"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_8"
type: "PReLU"
bottom: "conv4_8"
top: "conv4_8"
}
layer {
name: "res4_8"
type: "Eltwise"
bottom: "res4_6"
bottom: "conv4_8"
top: "res4_8"
eltwise_param {
operation: 1
}
}
layer {
name: "conv4_9"
type: "Convolution"
bottom: "res4_8"
top: "conv4_9"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_9"
type: "PReLU"
bottom: "conv4_9"
top: "conv4_9"
}
layer {
name: "conv4_10"
type: "Convolution"
bottom: "conv4_9"
top: "conv4_10"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_10"
type: "PReLU"
bottom: "conv4_10"
top: "conv4_10"
}
layer {
name: "res4_10"
type: "Eltwise"
bottom: "res4_8"
bottom: "conv4_10"
top: "res4_10"
eltwise_param {
operation: 1
}
}
layer {
name: "conv4"
type: "Convolution"
bottom: "res4_10"
top: "conv4"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 512
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4"
type: "PReLU"
bottom: "conv4"
top: "conv4"
}
layer {
name: "pool4"
type: "Pooling"
bottom: "conv4"
top: "pool4"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
layer {
name: "conv5_1"
type: "Convolution"
bottom: "pool4"
top: "conv5_1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 512
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu5_1"
type: "PReLU"
bottom: "conv5_1"
top: "conv5_1"
}
layer {
name: "conv5_2"
type: "Convolution"
bottom: "conv5_1"
top: "conv5_2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 512
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu5_2"
type: "PReLU"
bottom: "conv5_2"
top: "conv5_2"
}
layer {
name: "res5_2"
type: "Eltwise"
bottom: "pool4"
bottom: "conv5_2"
top: "res5_2"
eltwise_param {
operation: 1
}
}
layer {
name: "conv5_3"
type: "Convolution"
bottom: "res5_2"
top: "conv5_3"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 512
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu5_3"
type: "PReLU"
bottom: "conv5_3"
top: "conv5_3"
}
layer {
name: "conv5_4"
type: "Convolution"
bottom: "conv5_3"
top: "conv5_4"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 512
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu5_4"
type: "PReLU"
bottom: "conv5_4"
top: "conv5_4"
}
layer {
name: "res5_4"
type: "Eltwise"
bottom: "res5_2"
bottom: "conv5_4"
top: "res5_4"
eltwise_param {
operation: 1
}
}
layer {
name: "conv5_5"
type: "Convolution"
bottom: "res5_4"
top: "conv5_5"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 512
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu5_5"
type: "PReLU"
bottom: "conv5_5"
top: "conv5_5"
}
layer {
name: "conv5_6"
type: "Convolution"
bottom: "conv5_5"
top: "conv5_6"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 512
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu5_6"
type: "PReLU"
bottom: "conv5_6"
top: "conv5_6"
}
layer {
name: "res5_6"
type: "Eltwise"
bottom: "res5_4"
bottom: "conv5_6"
top: "res5_6"
eltwise_param {
operation: 1
}
}
layer {
name: "fc5"
type: "InnerProduct"
bottom: "res5_6"
top: "fc5"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 512
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
针对上面的原始网络结构,需要对其进行更改,更改Prelu层,为什么要对Prelu层进行修改,原因:Prelu是使用caffe中的gpu源码(尽管nvidia官网说,已经支持Prelu,但是我没有找到相应的使用方法;同时网上也有人说nvidia所支持的Prelu,实质是Lrelu,根本没有实现Prelu。所以自己在Plugin中加入了相应的Prelu的实现)。
更改后是这样的:
name: "face_res27net"
input: "data"
input_dim: 1
input_dim: 3
input_dim: 128
input_dim: 128
layer {
name: "conv1a"
type: "Convolution"
bottom: "data"
top: "conv1a"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 32
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu1a"
type: "IPlugin"
bottom: "conv1a"
top: "conv1a"
}
layer {
name: "conv1b"
type: "Convolution"
bottom: "conv1a"
top: "conv1b"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu1b"
type: "IPlugin"
bottom: "conv1b"
top: "conv1b"
}
layer {
name: "pool1b"
type: "Pooling"
bottom: "conv1b"
top: "pool1b"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
layer {
name: "conv2_1"
type: "Convolution"
bottom: "pool1b"
top: "conv2_1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu2_1"
type: "IPlugin"
bottom: "conv2_1"
top: "conv2_1"
}
layer {
name: "conv2_2"
type: "Convolution"
bottom: "conv2_1"
top: "conv2_2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 64
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu2_2"
type: "IPlugin"
bottom: "conv2_2"
top: "conv2_2"
}
layer {
name: "res2_2"
type: "Eltwise"
bottom: "pool1b"
bottom: "conv2_2"
top: "res2_2"
eltwise_param {
operation: 1
}
}
layer {
name: "conv2"
type: "Convolution"
bottom: "res2_2"
top: "conv2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu2"
type: "IPlugin"
bottom: "conv2"
top: "conv2"
}
layer {
name: "pool2"
type: "Pooling"
bottom: "conv2"
top: "pool2"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
layer {
name: "conv3_1"
type: "Convolution"
bottom: "pool2"
top: "conv3_1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu3_1"
type: "IPlugin"
bottom: "conv3_1"
top: "conv3_1"
}
layer {
name: "conv3_2"
type: "Convolution"
bottom: "conv3_1"
top: "conv3_2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu3_2"
type: "IPlugin"
bottom: "conv3_2"
top: "conv3_2"
}
layer {
name: "res3_2"
type: "Eltwise"
bottom: "pool2"
bottom: "conv3_2"
top: "res3_2"
eltwise_param {
operation: 1
}
}
layer {
name: "conv3_3"
type: "Convolution"
bottom: "res3_2"
top: "conv3_3"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu3_3"
type: "IPlugin"
bottom: "conv3_3"
top: "conv3_3"
}
layer {
name: "conv3_4"
type: "Convolution"
bottom: "conv3_3"
top: "conv3_4"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 128
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu3_4"
type: "IPlugin"
bottom: "conv3_4"
top: "conv3_4"
}
layer {
name: "res3_4"
type: "Eltwise"
bottom: "res3_2"
bottom: "conv3_4"
top: "res3_4"
eltwise_param {
operation: 1
}
}
layer {
name: "conv3"
type: "Convolution"
bottom: "res3_4"
top: "conv3"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu3"
type: "IPlugin"
bottom: "conv3"
top: "conv3"
}
layer {
name: "pool3"
type: "Pooling"
bottom: "conv3"
top: "pool3"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
layer {
name: "conv4_1"
type: "Convolution"
bottom: "pool3"
top: "conv4_1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_1"
type: "IPlugin"
bottom: "conv4_1"
top: "conv4_1"
}
layer {
name: "conv4_2"
type: "Convolution"
bottom: "conv4_1"
top: "conv4_2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_2"
type: "IPlugin"
bottom: "conv4_2"
top: "conv4_2"
}
layer {
name: "res4_2"
type: "Eltwise"
bottom: "pool3"
bottom: "conv4_2"
top: "res4_2"
eltwise_param {
operation: 1
}
}
layer {
name: "conv4_3"
type: "Convolution"
bottom: "res4_2"
top: "conv4_3"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_3"
type: "IPlugin"
bottom: "conv4_3"
top: "conv4_3"
}
layer {
name: "conv4_4"
type: "Convolution"
bottom: "conv4_3"
top: "conv4_4"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_4"
type: "IPlugin"
bottom: "conv4_4"
top: "conv4_4"
}
layer {
name: "res4_4"
type: "Eltwise"
bottom: "res4_2"
bottom: "conv4_4"
top: "res4_4"
eltwise_param {
operation: 1
}
}
layer {
name: "conv4_5"
type: "Convolution"
bottom: "res4_4"
top: "conv4_5"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_5"
type: "IPlugin"
bottom: "conv4_5"
top: "conv4_5"
}
layer {
name: "conv4_6"
type: "Convolution"
bottom: "conv4_5"
top: "conv4_6"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_6"
type: "IPlugin"
bottom: "conv4_6"
top: "conv4_6"
}
layer {
name: "res4_6"
type: "Eltwise"
bottom: "res4_4"
bottom: "conv4_6"
top: "res4_6"
eltwise_param {
operation: 1
}
}
layer {
name: "conv4_7"
type: "Convolution"
bottom: "res4_6"
top: "conv4_7"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_7"
type: "IPlugin"
bottom: "conv4_7"
top: "conv4_7"
}
layer {
name: "conv4_8"
type: "Convolution"
bottom: "conv4_7"
top: "conv4_8"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_8"
type: "IPlugin"
bottom: "conv4_8"
top: "conv4_8"
}
layer {
name: "res4_8"
type: "Eltwise"
bottom: "res4_6"
bottom: "conv4_8"
top: "res4_8"
eltwise_param {
operation: 1
}
}
layer {
name: "conv4_9"
type: "Convolution"
bottom: "res4_8"
top: "conv4_9"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_9"
type: "IPlugin"
bottom: "conv4_9"
top: "conv4_9"
}
layer {
name: "conv4_10"
type: "Convolution"
bottom: "conv4_9"
top: "conv4_10"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 256
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4_10"
type: "IPlugin"
bottom: "conv4_10"
top: "conv4_10"
}
layer {
name: "res4_10"
type: "Eltwise"
bottom: "res4_8"
bottom: "conv4_10"
top: "res4_10"
eltwise_param {
operation: 1
}
}
layer {
name: "conv4"
type: "Convolution"
bottom: "res4_10"
top: "conv4"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 512
kernel_size: 3
stride: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu4"
type: "IPlugin"
bottom: "conv4"
top: "conv4"
}
layer {
name: "pool4"
type: "Pooling"
bottom: "conv4"
top: "pool4"
pooling_param {
pool: MAX
kernel_size: 2
stride: 2
}
}
layer {
name: "conv5_1"
type: "Convolution"
bottom: "pool4"
top: "conv5_1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 512
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu5_1"
type: "IPlugin"
bottom: "conv5_1"
top: "conv5_1"
}
layer {
name: "conv5_2"
type: "Convolution"
bottom: "conv5_1"
top: "conv5_2"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 512
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu5_2"
type: "IPlugin"
bottom: "conv5_2"
top: "conv5_2"
}
layer {
name: "res5_2"
type: "Eltwise"
bottom: "pool4"
bottom: "conv5_2"
top: "res5_2"
eltwise_param {
operation: 1
}
}
layer {
name: "conv5_3"
type: "Convolution"
bottom: "res5_2"
top: "conv5_3"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 512
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu5_3"
type: "IPlugin"
bottom: "conv5_3"
top: "conv5_3"
}
layer {
name: "conv5_4"
type: "Convolution"
bottom: "conv5_3"
top: "conv5_4"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 512
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu5_4"
type: "IPlugin"
bottom: "conv5_4"
top: "conv5_4"
}
layer {
name: "res5_4"
type: "Eltwise"
bottom: "res5_2"
bottom: "conv5_4"
top: "res5_4"
eltwise_param {
operation: 1
}
}
layer {
name: "conv5_5"
type: "Convolution"
bottom: "res5_4"
top: "conv5_5"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 512
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu5_5"
type: "IPlugin"
bottom: "conv5_5"
top: "conv5_5"
}
layer {
name: "conv5_6"
type: "Convolution"
bottom: "conv5_5"
top: "conv5_6"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 0
decay_mult: 0
}
convolution_param {
num_output: 512
kernel_size: 3
stride: 1
pad: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu5_6"
type: "IPlugin"
bottom: "conv5_6"
top: "conv5_6"
}
layer {
name: "res5_6"
type: "Eltwise"
bottom: "res5_4"
bottom: "conv5_6"
top: "res5_6"
eltwise_param {
operation: 1
}
}
layer {
name: "fc5"
type: "InnerProduct"
bottom: "res5_6"
top: "fc5"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 512
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
然后进行相应的模型解析;
1.Prelu代码的实现,我参考的代码在这个位置:https://github.com/Goingqs/TensorRT-Prelu
同时我将代码也上传到这个位置了:https://download.csdn.net/download/qq_22764813/10727259(我的资源页)
2.在比对网络结构fc5的输出的时候,输出特征参数只有一半是正确,有一般为0,错误的原因是我这个代码使用错误:
cudaMemcpyAsync( data_cpu, data_gpu, sizeof(float)*count, cudaMemcpyDeviceToHost, stream);
这个函数中的第三个参数是所占用的字节byte数,但是在使用时,我只填入的count(数据的个数),所以在数据在内存拷贝的时候出现了问题,只拷贝了部分数据;