diff --git a/models/CNN_ResNet_21/WiAU_v2.0.prototxt b/models/CNN_ResNet_21/WiAU_v2.0.prototxt new file mode 100644 index 000000000..5b5e5fdc1 --- /dev/null +++ b/models/CNN_ResNet_21/WiAU_v2.0.prototxt @@ -0,0 +1,2528 @@ +name: "WiAU_v2" +layer { + name: "data" + type: "Data" + top: "data" + top: "label" + include { + phase: TRAIN + } + transform_param { + scale: 0.02 + } + data_param { + source: "WiAU_v2/train" + batch_size: 50 + backend: LMDB + } +} +layer { + name: "data" + type: "Data" + top: "data" + top: "label" + include { + phase: TEST + } + transform_param { + scale: 0.02 + } + data_param { + source: "WiAU_v2/test" + batch_size: 50 + backend: LMDB + } +} + +layer { + name: "conv1" + type: "Convolution" + bottom: "data" + top: "conv1" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 64 + kernel_size: 7 + stride: 2 + pad: 2 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu1" + type:"ReLU" + bottom:"conv1" + top:"conv1" +} + +layer{ + name:"pool1" + type:"Pooling" + bottom:"conv1" + top:"pool1" + pooling_param{ + pool:MAX + kernel_h: 3 + kernel_w: 3 + stride_h: 2 + stride_w: 2 + pad: 0 + } +} +layer { + name: "conv2" + type: "Convolution" + bottom: "pool1" + top: "conv2" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} + + + + +layer { + name: "conv_a1_in" + type: "Convolution" + bottom: "conv2" + top: "conv_a1_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 32 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_a1_in" + type:"ReLU" + bottom:"conv_a1_in" + top:"conv_a1_in" +} +layer { + name: "conv_a1_bottleneck" + type: "Convolution" + bottom: "conv_a1_in" + top: "conv_a1_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 32 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_a1_bottleneck" + type:"ReLU" + bottom:"conv_a1_bottleneck" + top:"conv_a1_bottleneck" +} +layer { + name: "conv_a1_out" + type: "Convolution" + bottom: "conv_a1_bottleneck" + top: "conv_a1_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_a1_out" + type:"ReLU" + bottom:"conv_a1_out" + top:"conv_a1_out" +} +layer { + name: "conv_a1_sum" + type: "Eltwise" + bottom: "conv_a1_out" + bottom: "conv2" + top: "conv_a1_sum" + eltwise_param { + operation: SUM + } +} + + +layer { + name: "conv_a2_in" + type: "Convolution" + bottom: "conv_a1_sum" + top: "conv_a2_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 32 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_a2_in" + type:"ReLU" + bottom:"conv_a2_in" + top:"conv_a2_in" +} + +layer { + name: "conv_a2_bottleneck" + type: "Convolution" + bottom: "conv_a2_in" + top: "conv_a2_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 32 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_a2_bottleneck" + type:"ReLU" + bottom:"conv_a2_bottleneck" + top:"conv_a2_bottleneck" +} +layer { + name: "conv_a2_out" + type: "Convolution" + bottom: "conv_a2_bottleneck" + top: "conv_a2_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_a2_out" + type:"ReLU" + bottom:"conv_a2_out" + top:"conv_a2_out" +} +layer { + name: "conv_a2_sum" + type: "Eltwise" + bottom: "conv_a2_out" + bottom: "conv_a1_sum" + top: "conv_a2_sum" + eltwise_param { + operation: SUM + } +} + +layer { + name: "conv_a3_in" + type: "Convolution" + bottom: "conv_a2_sum" + top: "conv_a3_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 32 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_a3_in" + type:"ReLU" + bottom:"conv_a3_in" + top:"conv_a3_in" +} +layer { + name: "conv_a3_bottleneck" + type: "Convolution" + bottom: "conv_a3_in" + top: "conv_a3_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 32 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_a3_bottleneck" + type:"ReLU" + bottom:"conv_a3_bottleneck" + top:"conv_a3_bottleneck" +} +layer { + name: "conv_a3_out" + type: "Convolution" + bottom: "conv_a3_bottleneck" + top: "conv_a3_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_a3_out" + type:"ReLU" + bottom:"conv_a3_out" + top:"conv_a3_out" +} +layer { + name: "conv_a3_sum" + type: "Eltwise" + bottom: "conv_a3_out" + bottom: "conv_a2_sum" + top: "conv_a3_sum" + eltwise_param { + operation: SUM + } +} + +layer { + name: "conv_a3_upscale" + type: "Convolution" + bottom: "conv_a3_sum" + top: "conv_a3_upscale" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} + + + + + + + + + +layer { + name: "conv_b1_in" + type: "Convolution" + bottom: "conv_a3_upscale" + top: "conv_b1_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 32 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_b1_in" + type:"ReLU" + bottom:"conv_b1_in" + top:"conv_b1_in" +} +layer { + name: "conv_b1_bottleneck" + type: "Convolution" + bottom: "conv_b1_in" + top: "conv_b1_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 32 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_b1_bottleneck" + type:"ReLU" + bottom:"conv_b1_bottleneck" + top:"conv_b1_bottleneck" +} +layer { + name: "conv_b1_out" + type: "Convolution" + bottom: "conv_b1_bottleneck" + top: "conv_b1_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_b1_out" + type:"ReLU" + bottom:"conv_b1_out" + top:"conv_b1_out" +} +layer { + name: "conv_b1_sum" + type: "Eltwise" + bottom: "conv_b1_out" + bottom: "conv_a3_sum" + top: "conv_b1_sum" + eltwise_param { + operation: SUM + } +} + + +layer { + name: "conv_b2_in" + type: "Convolution" + bottom: "conv_b1_sum" + top: "conv_b2_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 32 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_b2_in" + type:"ReLU" + bottom:"conv_b2_in" + top:"conv_b2_in" +} + +layer { + name: "conv_b2_bottleneck" + type: "Convolution" + bottom: "conv_b2_in" + top: "conv_b2_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 32 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_b2_bottleneck" + type:"ReLU" + bottom:"conv_b2_bottleneck" + top:"conv_b2_bottleneck" +} +layer { + name: "conv_b2_out" + type: "Convolution" + bottom: "conv_b2_bottleneck" + top: "conv_b2_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_b2_out" + type:"ReLU" + bottom:"conv_b2_out" + top:"conv_b2_out" +} +layer { + name: "conv_b2_sum" + type: "Eltwise" + bottom: "conv_b2_out" + bottom: "conv_b1_sum" + top: "conv_b2_sum" + eltwise_param { + operation: SUM + } +} + +layer { + name: "conv_b3_in" + type: "Convolution" + bottom: "conv_b2_sum" + top: "conv_b3_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 32 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_b3_in" + type:"ReLU" + bottom:"conv_b3_in" + top:"conv_b3_in" +} +layer { + name: "conv_b3_bottleneck" + type: "Convolution" + bottom: "conv_b3_in" + top: "conv_b3_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 32 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_b3_bottleneck" + type:"ReLU" + bottom:"conv_b3_bottleneck" + top:"conv_b3_bottleneck" +} +layer { + name: "conv_b3_out" + type: "Convolution" + bottom: "conv_b3_bottleneck" + top: "conv_b3_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_b3_out" + type:"ReLU" + bottom:"conv_b3_out" + top:"conv_b3_out" +} +layer { + name: "conv_b3_sum" + type: "Eltwise" + bottom: "conv_b3_out" + bottom: "conv_b2_sum" + top: "conv_b3_sum" + eltwise_param { + operation: SUM + } +} + +layer { + name: "conv_b3_upscale" + type: "Convolution" + bottom: "conv_b3_sum" + top: "conv_b3_upscale" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} + + + + + + + + + +layer { + name: "conv_c1_in" + type: "Convolution" + bottom: "conv_b3_upscale" + top: "conv_c1_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 64 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_c1_in" + type:"ReLU" + bottom:"conv_c1_in" + top:"conv_c1_in" +} +layer { + name: "conv_c1_bottleneck" + type: "Convolution" + bottom: "conv_c1_in" + top: "conv_c1_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 64 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_c1_bottleneck" + type:"ReLU" + bottom:"conv_c1_bottleneck" + top:"conv_c1_bottleneck" +} +layer { + name: "conv_c1_out" + type: "Convolution" + bottom: "conv_c1_bottleneck" + top: "conv_c1_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 256 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_c1_out" + type:"ReLU" + bottom:"conv_c1_out" + top:"conv_c1_out" +} +layer { + name: "conv_c1_sum" + type: "Eltwise" + bottom: "conv_c1_out" + bottom: "conv_b3_sum" + top: "conv_c1_sum" + eltwise_param { + operation: SUM + } +} + + +layer { + name: "conv_c2_in" + type: "Convolution" + bottom: "conv_c1_sum" + top: "conv_c2_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 64 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_c2_in" + type:"ReLU" + bottom:"conv_c2_in" + top:"conv_c2_in" +} + +layer { + name: "conv_c2_bottleneck" + type: "Convolution" + bottom: "conv_c2_in" + top: "conv_c2_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 64 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_c2_bottleneck" + type:"ReLU" + bottom:"conv_c2_bottleneck" + top:"conv_c2_bottleneck" +} +layer { + name: "conv_c2_out" + type: "Convolution" + bottom: "conv_c2_bottleneck" + top: "conv_c2_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 256 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_c2_out" + type:"ReLU" + bottom:"conv_c2_out" + top:"conv_c2_out" +} +layer { + name: "conv_c2_sum" + type: "Eltwise" + bottom: "conv_c2_out" + bottom: "conv_c1_sum" + top: "conv_c2_sum" + eltwise_param { + operation: SUM + } +} + +layer { + name: "conv_c3_in" + type: "Convolution" + bottom: "conv_c2_sum" + top: "conv_c3_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 64 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_c3_in" + type:"ReLU" + bottom:"conv_c3_in" + top:"conv_c3_in" +} +layer { + name: "conv_c3_bottleneck" + type: "Convolution" + bottom: "conv_c3_in" + top: "conv_c3_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 64 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_c3_bottleneck" + type:"ReLU" + bottom:"conv_c3_bottleneck" + top:"conv_c3_bottleneck" +} +layer { + name: "conv_c3_out" + type: "Convolution" + bottom: "conv_c3_bottleneck" + top: "conv_c3_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 256 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_c3_out" + type:"ReLU" + bottom:"conv_c3_out" + top:"conv_c3_out" +} +layer { + name: "conv_c3_sum" + type: "Eltwise" + bottom: "conv_c3_out" + bottom: "conv_c2_sum" + top: "conv_c3_sum" + eltwise_param { + operation: SUM + } +} + +layer { + name: "conv_c3_upscale" + type: "Convolution" + bottom: "conv_c3_sum" + top: "conv_c3_upscale" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 256 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} + + + + + + + + + +layer { + name: "conv_d1_in" + type: "Convolution" + bottom: "conv_c3_upscale" + top: "conv_d1_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 64 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_d1_in" + type:"ReLU" + bottom:"conv_d1_in" + top:"conv_d1_in" +} +layer { + name: "conv_d1_bottleneck" + type: "Convolution" + bottom: "conv_d1_in" + top: "conv_d1_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 64 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_d1_bottleneck" + type:"ReLU" + bottom:"conv_d1_bottleneck" + top:"conv_d1_bottleneck" +} +layer { + name: "conv_d1_out" + type: "Convolution" + bottom: "conv_d1_bottleneck" + top: "conv_d1_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 256 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_d1_out" + type:"ReLU" + bottom:"conv_d1_out" + top:"conv_d1_out" +} +layer { + name: "conv_d1_sum" + type: "Eltwise" + bottom: "conv_d1_out" + bottom: "conv_c3_sum" + top: "conv_d1_sum" + eltwise_param { + operation: SUM + } +} + + +layer { + name: "conv_d2_in" + type: "Convolution" + bottom: "conv_d1_sum" + top: "conv_d2_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 64 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_d2_in" + type:"ReLU" + bottom:"conv_d2_in" + top:"conv_d2_in" +} + +layer { + name: "conv_d2_bottleneck" + type: "Convolution" + bottom: "conv_d2_in" + top: "conv_d2_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 64 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_d2_bottleneck" + type:"ReLU" + bottom:"conv_d2_bottleneck" + top:"conv_d2_bottleneck" +} +layer { + name: "conv_d2_out" + type: "Convolution" + bottom: "conv_d2_bottleneck" + top: "conv_d2_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 256 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_d2_out" + type:"ReLU" + bottom:"conv_d2_out" + top:"conv_d2_out" +} +layer { + name: "conv_d2_sum" + type: "Eltwise" + bottom: "conv_d2_out" + bottom: "conv_d1_sum" + top: "conv_d2_sum" + eltwise_param { + operation: SUM + } +} + +layer { + name: "conv_d3_in" + type: "Convolution" + bottom: "conv_d2_sum" + top: "conv_d3_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 64 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_d3_in" + type:"ReLU" + bottom:"conv_d3_in" + top:"conv_d3_in" +} +layer { + name: "conv_d3_bottleneck" + type: "Convolution" + bottom: "conv_d3_in" + top: "conv_d3_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 64 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_d3_bottleneck" + type:"ReLU" + bottom:"conv_d3_bottleneck" + top:"conv_d3_bottleneck" +} +layer { + name: "conv_d3_out" + type: "Convolution" + bottom: "conv_d3_bottleneck" + top: "conv_d3_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 256 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_d3_out" + type:"ReLU" + bottom:"conv_d3_out" + top:"conv_d3_out" +} +layer { + name: "conv_d3_sum" + type: "Eltwise" + bottom: "conv_d3_out" + bottom: "conv_d2_sum" + top: "conv_d3_sum" + eltwise_param { + operation: SUM + } +} + +layer { + name: "conv_d3_upscale" + type: "Convolution" + bottom: "conv_d3_sum" + top: "conv_d3_upscale" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 256 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} + + + + + + + + + +layer { + name: "conv_e1_in" + type: "Convolution" + bottom: "conv_d3_upscale" + top: "conv_e1_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_e1_in" + type:"ReLU" + bottom:"conv_e1_in" + top:"conv_e1_in" +} +layer { + name: "conv_e1_bottleneck" + type: "Convolution" + bottom: "conv_e1_in" + top: "conv_e1_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_e1_bottleneck" + type:"ReLU" + bottom:"conv_e1_bottleneck" + top:"conv_e1_bottleneck" +} +layer { + name: "conv_e1_out" + type: "Convolution" + bottom: "conv_e1_bottleneck" + top: "conv_e1_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 512 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_e1_out" + type:"ReLU" + bottom:"conv_e1_out" + top:"conv_e1_out" +} +layer { + name: "conv_e1_sum" + type: "Eltwise" + bottom: "conv_e1_out" + bottom: "conv_d3_sum" + top: "conv_e1_sum" + eltwise_param { + operation: SUM + } +} + + +layer { + name: "conv_e2_in" + type: "Convolution" + bottom: "conv_e1_sum" + top: "conv_e2_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_e2_in" + type:"ReLU" + bottom:"conv_e2_in" + top:"conv_e2_in" +} + +layer { + name: "conv_e2_bottleneck" + type: "Convolution" + bottom: "conv_e2_in" + top: "conv_e2_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_e2_bottleneck" + type:"ReLU" + bottom:"conv_e2_bottleneck" + top:"conv_e2_bottleneck" +} +layer { + name: "conv_e2_out" + type: "Convolution" + bottom: "conv_e2_bottleneck" + top: "conv_e2_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 512 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_e2_out" + type:"ReLU" + bottom:"conv_e2_out" + top:"conv_e2_out" +} +layer { + name: "conv_e2_sum" + type: "Eltwise" + bottom: "conv_e2_out" + bottom: "conv_e1_sum" + top: "conv_e2_sum" + eltwise_param { + operation: SUM + } +} + +layer { + name: "conv_e3_in" + type: "Convolution" + bottom: "conv_e2_sum" + top: "conv_e3_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_e3_in" + type:"ReLU" + bottom:"conv_e3_in" + top:"conv_e3_in" +} +layer { + name: "conv_e3_bottleneck" + type: "Convolution" + bottom: "conv_e3_in" + top: "conv_e3_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_e3_bottleneck" + type:"ReLU" + bottom:"conv_e3_bottleneck" + top:"conv_e3_bottleneck" +} +layer { + name: "conv_e3_out" + type: "Convolution" + bottom: "conv_e3_bottleneck" + top: "conv_e3_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 512 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_e3_out" + type:"ReLU" + bottom:"conv_e3_out" + top:"conv_e3_out" +} +layer { + name: "conv_e3_sum" + type: "Eltwise" + bottom: "conv_e3_out" + bottom: "conv_e2_sum" + top: "conv_e3_sum" + eltwise_param { + operation: SUM + } +} + +layer { + name: "conv_e3_upscale" + type: "Convolution" + bottom: "conv_e3_sum" + top: "conv_e3_upscale" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 512 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} + + + + + + + + + +layer { + name: "conv_f1_in" + type: "Convolution" + bottom: "conv_e3_upscale" + top: "conv_f1_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_f1_in" + type:"ReLU" + bottom:"conv_f1_in" + top:"conv_f1_in" +} +layer { + name: "conv_f1_bottleneck" + type: "Convolution" + bottom: "conv_f1_in" + top: "conv_f1_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_f1_bottleneck" + type:"ReLU" + bottom:"conv_f1_bottleneck" + top:"conv_f1_bottleneck" +} +layer { + name: "conv_f1_out" + type: "Convolution" + bottom: "conv_f1_bottleneck" + top: "conv_f1_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 512 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_f1_out" + type:"ReLU" + bottom:"conv_f1_out" + top:"conv_f1_out" +} +layer { + name: "conv_f1_sum" + type: "Eltwise" + bottom: "conv_f1_out" + bottom: "conv_e3_sum" + top: "conv_f1_sum" + eltwise_param { + operation: SUM + } +} + + +layer { + name: "conv_f2_in" + type: "Convolution" + bottom: "conv_f1_sum" + top: "conv_f2_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_f2_in" + type:"ReLU" + bottom:"conv_f2_in" + top:"conv_f2_in" +} + +layer { + name: "conv_f2_bottleneck" + type: "Convolution" + bottom: "conv_f2_in" + top: "conv_f2_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_f2_bottleneck" + type:"ReLU" + bottom:"conv_f2_bottleneck" + top:"conv_f2_bottleneck" +} +layer { + name: "conv_f2_out" + type: "Convolution" + bottom: "conv_f2_bottleneck" + top: "conv_f2_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 512 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_f2_out" + type:"ReLU" + bottom:"conv_f2_out" + top:"conv_f2_out" +} +layer { + name: "conv_f2_sum" + type: "Eltwise" + bottom: "conv_f2_out" + bottom: "conv_f1_sum" + top: "conv_f2_sum" + eltwise_param { + operation: SUM + } +} + +layer { + name: "conv_f3_in" + type: "Convolution" + bottom: "conv_f2_sum" + top: "conv_f3_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_f3_in" + type:"ReLU" + bottom:"conv_f3_in" + top:"conv_f3_in" +} +layer { + name: "conv_f3_bottleneck" + type: "Convolution" + bottom: "conv_f3_in" + top: "conv_f3_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 128 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_f3_bottleneck" + type:"ReLU" + bottom:"conv_f3_bottleneck" + top:"conv_f3_bottleneck" +} +layer { + name: "conv_f3_out" + type: "Convolution" + bottom: "conv_f3_bottleneck" + top: "conv_f3_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 512 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_f3_out" + type:"ReLU" + bottom:"conv_f3_out" + top:"conv_f3_out" +} +layer { + name: "conv_f3_sum" + type: "Eltwise" + bottom: "conv_f3_out" + bottom: "conv_f2_sum" + top: "conv_f3_sum" + eltwise_param { + operation: SUM + } +} + +layer { + name: "conv_f3_upscale" + type: "Convolution" + bottom: "conv_f3_sum" + top: "conv_f3_upscale" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 512 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} + + + + + + + + + +layer { + name: "conv_g1_in" + type: "Convolution" + bottom: "conv_f3_upscale" + top: "conv_g1_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 256 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_g1_in" + type:"ReLU" + bottom:"conv_g1_in" + top:"conv_g1_in" +} +layer { + name: "conv_g1_bottleneck" + type: "Convolution" + bottom: "conv_g1_in" + top: "conv_g1_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 256 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_g1_bottleneck" + type:"ReLU" + bottom:"conv_g1_bottleneck" + top:"conv_g1_bottleneck" +} +layer { + name: "conv_g1_out" + type: "Convolution" + bottom: "conv_g1_bottleneck" + top: "conv_g1_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 1024 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_g1_out" + type:"ReLU" + bottom:"conv_g1_out" + top:"conv_g1_out" +} +layer { + name: "conv_g1_sum" + type: "Eltwise" + bottom: "conv_g1_out" + bottom: "conv_f3_sum" + top: "conv_g1_sum" + eltwise_param { + operation: SUM + } +} + + +layer { + name: "conv_g2_in" + type: "Convolution" + bottom: "conv_g1_sum" + top: "conv_g2_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 256 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_g2_in" + type:"ReLU" + bottom:"conv_g2_in" + top:"conv_g2_in" +} + +layer { + name: "conv_g2_bottleneck" + type: "Convolution" + bottom: "conv_g2_in" + top: "conv_g2_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 256 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_g2_bottleneck" + type:"ReLU" + bottom:"conv_g2_bottleneck" + top:"conv_g2_bottleneck" +} +layer { + name: "conv_g2_out" + type: "Convolution" + bottom: "conv_g2_bottleneck" + top: "conv_g2_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 1024 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_g2_out" + type:"ReLU" + bottom:"conv_g2_out" + top:"conv_g2_out" +} +layer { + name: "conv_g2_sum" + type: "Eltwise" + bottom: "conv_g2_out" + bottom: "conv_g1_sum" + top: "conv_g2_sum" + eltwise_param { + operation: SUM + } +} + +layer { + name: "conv_g3_in" + type: "Convolution" + bottom: "conv_g2_sum" + top: "conv_g3_in" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 256 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_g3_in" + type:"ReLU" + bottom:"conv_g3_in" + top:"conv_g3_in" +} +layer { + name: "conv_g3_bottleneck" + type: "Convolution" + bottom: "conv_g3_in" + top: "conv_g3_bottleneck" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 256 + kernel_size: 3 + stride: 1 + pad: 1 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_g3_bottleneck" + type:"ReLU" + bottom:"conv_g3_bottleneck" + top:"conv_g3_bottleneck" +} +layer { + name: "conv_g3_out" + type: "Convolution" + bottom: "conv_g3_bottleneck" + top: "conv_g3_out" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 1024 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} +layer{ + name:"relu_g3_out" + type:"ReLU" + bottom:"conv_g3_out" + top:"conv_g3_out" +} +layer { + name: "conv_g3_sum" + type: "Eltwise" + bottom: "conv_g3_out" + bottom: "conv_g2_sum" + top: "conv_g3_sum" + eltwise_param { + operation: SUM + } +} + +layer { + name: "conv_g3_upscale" + type: "Convolution" + bottom: "conv_g3_sum" + top: "conv_g3_upscale" + param { + lr_mult: 1 + } + param { + lr_mult: 2 + } + convolution_param { + num_output: 1024 + kernel_size: 1 + stride: 1 + pad: 0 + weight_filler { + type: "xavier" + } + bias_filler { + type: "constant" + } + } +} + + + + + + + + + +layer{ + name:"pool2" + type:"Pooling" + bottom:"conv_g3_upscale" + top:"pool2" + pooling_param{ + pool:AVG + kernel_h: 2 + kernel_w: 2 + stride_h: 1 + stride_w: 1 + pad: 0 + } +} +layer{ + name:"reshape1" + type:"Reshape" + bottom:"pool2" + top:"reshape1" + reshape_param { + shape { + dim:0 + dim:0 + dim:32 + dim:-1 + } + } +} + + + + +layer { + name: "loss" + type: "SoftmaxWithLoss" + bottom: "reshape1" + bottom: "label" + top: "loss" +} +layer{ + name:"cross" + type:"SigmoidCrossEntropyLossLayer" + bottom:"loss" + bottom:"label" + top:"cross" +} +layer { + name: "Accuracy" + type: "Accuracy" + bottom: "loss" + bottom: "label" + top: "Accuracy" +} diff --git a/models/CNN_ResNet_21/solver.prototxt b/models/CNN_ResNet_21/solver.prototxt new file mode 100644 index 000000000..0684bfc7b --- /dev/null +++ b/models/CNN_ResNet_21/solver.prototxt @@ -0,0 +1,22 @@ +net: "WiAU_2.0_CNN+ResNet.prototxt" + +test_iter: 100 + +test_interval: 400 + +base_lr: 0.01 +momentum: 0.9 +weight_decay: 0.0005 + +lr_policy: "inv" +gamma: 0.0001 +power: 0.75 + +display: 100 + +max_iter: 100000 + +snapshot: 5000 +snapshot_prefix: "WiAU_v2/result" + +solver_mode: GPU diff --git a/python/Transform.py b/python/Transform.py new file mode 100644 index 000000000..775960e2a --- /dev/null +++ b/python/Transform.py @@ -0,0 +1,247 @@ +import numpy as np +import matplotlib.pyplot as plt +from matplotlib import animation +import os +import pickle +import cmath +import math +import scipy.stats as scita +import scipy.signal as signal +import scipy.io as scio +from numpy import linalg as la +from numpy import * +import lmdb +import caffe + +winLen=30 + +def db(x): +#变换到log空间 + if (x==0): + ans=0 + else: + ans=20*(np.log10(x)) + return ans + +def butterworth_II(file,Fc): +#去噪 + N = 2 # Filter order + Wn = 2*(np.pi)*Fc # Cutoff frequency + B, A = signal.butter(N, Wn, output='ba') + ret = signal.filtfilt(B,A,file) + return ret + +def relative_phase(tmp1,tmp2): +#计算相对相位 + tmp=tmp1*np.conjugate(tmp2) + tmp_1=(tmp.real)/(abs(tmp)) + ret=np.arccos(tmp_1) + + return (ret) + + + + +def file_data(filename): +#解析原始数据包 + l=[] + with open(filename, "rb") as f: + while 1: + try: + flag = 1 + k = pickle.load(f) + for i in range(90): + if(abs(k[i]) <= 0): + flag = 0 + if flag == 0: + continue + l.append(k[0:90]) + except Exception as e: + break + a = np.array(l).T + return(a) + +def csi_amplitude(file): + [row,col]=file.shape + newFile = np.zeros((row,col)) + for i in range(row): + for j in range(col): + newFile[i,j]=db(abs(file[i,j])) + #print (file[i,j]) + ret=np.array(newFile) + return (ret.real) + +def csi_relative_phase(file): +#计算数据的相对相位 + file=file.reshape(3,30,-1) + [row,col,other]=file.shape + csi_ant1=file[0] + csi_ant2=file[1] + csi_ant3=file[2] + rephase1_2=[] + rephase1_3=[] + rephase3_2=[] + rephase_all=[] + + for i in range(col): + tmp1_2=relative_phase(csi_ant1[i],csi_ant2[i]) + + tmp1_3=relative_phase(csi_ant1[i],csi_ant3[i]) + tmp3_2=relative_phase(csi_ant3[i],csi_ant2[i]) + rephase1_2.append(tmp1_2) + rephase1_3.append(tmp1_3) + rephase3_2.append(tmp3_2) + + for j in range(30): + rephase_all.append(rephase1_2[j]) + for j in range(30): + rephase_all.append(rephase1_3[j]) + for j in range(30): + rephase_all.append(rephase3_2[j]) + + ret=np.array(rephase_all) + return ret.real + +def get_characters(matrix, num, label): +#计算出相应特征值 + max = [] + min = [] + mean = [] + skewness = [] + kurtosis = [] + std = [] + i = 1 + col = matrix.shape[1] + chunk = int(col / num) + while (i) * chunk <= col and i <= num: + tmp = matrix[:, chunk * (i-1):chunk * (i)] + i = i + 1 + cnt = 0 + max_t = [] + min_t = [] + mean_t = [] + skewness_t = [] + kurtosis_t = [] + std_t = [] + while cnt < 90: + t = tmp[cnt:] + max_t.append(np.max(t)) + min_t.append(np.min(t)) + mean_t.append(np.mean(t)) + skewness_t.append(np.mean(scita.skew(t,axis=1, bias=True))) + kurtosis_t.append(np.mean(scita.kurtosis(t,axis=1, bias=True))) + std_t.append(np.std(t)) + cnt = cnt + 1 + max.append(max_t) + min.append(min_t) + mean.append(mean_t) + skewness.append(skewness_t) + kurtosis.append(kurtosis_t) + std.append(std_t) + l = [] + for i in range(0, 540): + l.append(label) + max = np.array(max).T + min = np.array(min).T + mean = np.array(mean).T + skewness = np.array(skewness).T + kurtosis = np.array(kurtosis).T + std = np.array(std).T + result = np.append(max, min, axis=0) + result = np.append(result, mean, axis=0) + result = np.append(result, skewness, axis=0) + result = np.append(result, kurtosis, axis=0) + result = np.append(result, std, axis=0) + return result, l + +def classification(input): +#根据标签list转化为标签矩阵(one-hot编码) + labelOrder=set() + labelList=[] + i=0 + for label in input: + label=label.split('_')[0] + labelList.append(label) + labelOrder.add(label) + labelOrder=list(labelOrder) + labelCol=len(labelOrder) + labelMatrix = [] + for label in labelList: + l = [0] * labelCol + labelNum = labelOrder.index(label) + l[labelNum] = 1 + labelMatrix.append(l) + labelMatrix = np.array(labelMatrix, dtype=object) + print(labelMatrix.shape) + return labelMatrix,labelOrder + + + + + + +def train_data(path,num): +#输入为路径和特征值数量 + files= os.listdir(path) + labelList=[] + featureList=[] + for file in files: + if file == 'over': + continue + for x in os.listdir(path + '/' + file): + print(x) + csiData=file_data(str(path) + '/' + file + '/' + x) + csiAmplitude=csi_amplitude(csiData) + csiAmplitude=butterworth_II(csiAmplitude,0.03) + csiFeature, labels=get_characters(csiAmplitude,num,file) + labelList.extend(labels) + featureList.extend(csiFeature) + labelTmp=np.array(labelList) + featureMatrix=np.array(featureList) + labelMatrix,labelOrder=classification(labelTmp) + return featureMatrix,labelMatrix,labelOrder + + +def test_input(path,num): + files = os.listdir(path) + print(files) + featureList = [] + for file in files: + csiData = file_data(str(path) + '/' + file) + csiAmplitude = csi_amplitude(csiData) + csiAmplitude = butterworth_II(csiAmplitude, 0.03) + csiFeature, labels = get_characters(csiAmplitude, num, file) + featureList.extend(csiFeature) + featureMatrix = np.array(featureList) + return featureMatrix + +def turn_to_lmdb():#将csi数据转换为lmdb格式主文件 + data,label,labelOrder1=train_data(rootpath + '\\datatrain', 784) + N = 1000 + +# Let's pretend this is interesting data + X = data + y = label + +# We need to prepare the database for the size. We'll set it 10 times +# greater than what we theoretically need. There is little drawback to +# setting this too big. If you still run into problem after raising +# this, you might want to try saving fewer entries in a single +# transaction. + map_size = X.nbytes * 10 + env = lmdb.open('mylmdb', map_size=map_size) + + with env.begin(write=True) as txn: + # txn is a Transaction object + for i in range(N): + datum = caffe.proto.caffe_pb2.Datum()#处理好这五个变量即可 + datum.channels = X.shape[1] + datum.height = X.shape[2] + datum.width = X.shape[3] + datum.data = X[i].tobytes() # or .tostring() if numpy < 1.9 + datum.label = int(y[i]) + str_id = '{:08}'.format(i) + + # The encode is only essential in Python 3 + txn.put(str_id.encode('ascii'), datum.SerializeToString()) + env.close