我试图在 Caffe 中实现一个简单的网络来应对多目标回归。
我输入的维度是 5。我的输出维度是 3。
我在 mat 文件中有这些数据。
我已经使用h5create
andh5write
来创建train.h5
andtest.h5
文件。
load('train_data.mat')
h5create('train_data.h5','/data',[5 10000]);
h5write('train_data.h5', '/data', x');
load('train_label.mat')
h5create('train_label.h5','/label',[3 10000]);
h5write('train_label.h5', '/label', Y');
load('test_data.mat')
h5create('test_data.h5','/data',[5 2500]);
h5write('test_data.h5', '/data', x');
load('test_label.mat')
h5create('test_label.h5','/label',[3 2500]);
h5write('test_label.h5', '/label', Y');
我在 Caffe 中设计了一个网络如下:
name: "RegressionNet"
layer {
name: "data"
type: "HDF5Data"
top: "data"
top: "data"
include {
phase: TRAIN
}
hdf5_data_param {
source: "examples/my_second_cnn_example/data/train_data.txt"
batch_size: 10
}
}
layer {
name: "data"
type: "HDF5Data"
top: "label"
top: "label"
include {
phase: TRAIN
}
hdf5_data_param {
source: "examples/my_second_cnn_example/data/train_label.txt"
batch_size: 10
}
}
layer {
name: "data"
type: "HDF5Data"
top: "data"
top: "data"
include {
phase: TEST
}
hdf5_data_param {
source: "examples/my_second_cnn_example/data/test_data.txt"
batch_size: 10
}
}
layer {
name: "data"
type: "HDF5Data"
top: "label"
top: "label"
include {
phase: TEST
}
hdf5_data_param {
source: "examples/my_first_cnn_example/data/test_label.txt"
batch_size: 10
}
}
layer {
name: "fc1"
type: "InnerProduct"
bottom: "data"
top: "fc1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 3
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "loss"
type: "EuclideanLoss"
bottom: "fc1"
bottom: "label"
top: "loss"
}
layer {
name: "accuracy"
type: "Accuracy"
bottom: "fc1"
bottom: "label"
top: "accuracy"
include {
phase: TEST
}
}
不幸的是它不起作用!我收到以下错误
Check failed: outer_num_ * inner_num_ == bottom[1]->count() (10 vs. 30) Number of labels must match number of predictions; e.g., if label axis == 1 and prediction shape is (N, C, H, W), label count (number of labels) must be N*H*W, with integer values in {0, 1, ..., C-1}.
我认为问题在于我组织数据的方式。并且还在使用Accuracy层。
但是,关于如何解决它的任何想法?