我有一个有4个布尔输出的网络.这不是分类问题,而且每个问题都是有意义的.我期望每个人得到零或一个.现在我使用了欧几里德损失函数.
有1000000个样本.在输入文件中,每个都有144个功能,因此输入的大小为1000000*144.我使用批量大小为50,否则处理时间太长.输出文件的大小为1000000*4,即每个输入有四个输出.
当我使用精确度层时,它会抱怨输出的维度.它只需要一个布尔输出,而不是四个.我认为这是因为它将问题视为分类问题.我有两个问题.首先,考虑到精度层的误差,欧几里德损失函数是否适合这项任务?我如何才能获得网络的准确性?其次,我将获得四个变量中每个变量的预测输出的确切值.我的意思是我需要每个测试记录的确切预测值.现在,我只有每批的损失值.请指导我解决这些问题.
谢谢,Afshin
火车网络是:
{ state { phase: TRAIN } layer { name: "abbas" type: "HDF5Data" top: "data" top: "label" hdf5_data_param { source: "/home/afo214/Research/hdf5/simulation/Train-1000-11- 1/Train-Sc-B-1000-11-1.txt" batch_size: 50 } } layer { name: "ip1" type: "InnerProduct" bottom: "data" top: "ip1" inner_product_param { num_output: 350 weight_filler { type: "xavier" } } } layer { name: "sig1" bottom: "ip1" top: "sig1" type: "Sigmoid" } layer { name: "ip2" type: "InnerProduct" bottom: "sig1" top: "ip2" inner_product_param { num_output: 150 weight_filler { type: "xavier" } } }
测试网络还包括:
state { phase: TEST } layer { name: "abbas" type: "HDF5Data" top: "data" top: "label" hdf5_data_param { source: "/home/afo214/Research/hdf5/simulation/Train-1000-11- 1/Train-Sc-B-1000-11-1.txt" batch_size: 50 } } layer { name: "ip1" type: "InnerProduct" bottom: "data" top: "ip1" inner_product_param { num_output: 350 weight_filler { type: "xavier" } } } layer { name: "sig1" bottom: "ip1" top: "sig1" type: "Sigmoid" } layer { name: "ip2" type: "InnerProduct" bottom: "sig1" top: "ip2" inner_product_param { num_output: 150 weight_filler { type: "xavier" } } } layer { name: "sig2" bottom: "ip2" top: "sig2" type: "Sigmoid" } layer { name: "ip4" type: "InnerProduct" bottom: "sig2" top: "ip4" inner_product_param { num_output: 4 weight_filler { type: "xavier" } } } layer { name: "accuracy" type: "Accuracy" bottom: "ip4" bottom: "label" top: "accuracy" } layer { name: "loss" type: "EuclideanLoss" bottom: "ip4" bottom: "label" top: "loss" }
我收到这个错误:
accuracy_layer.cpp:34] Check failed: outer_num_ * inner_num_ == bottom[1]->count() (50 vs. 200) 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}.
没有使用精度层caffe给我的损失值.
"EuclideanLoss"
用于预测二进制输出?如果您正在尝试预测离散二进制标签,那么"EuclideanLoss"
这不是一个很好的选择.这种损失更适合于您希望预测连续值的回归任务(例如,估计边界框的协调等).
用于预测离散标签,"SoftmaxWithLoss"
或"InfogainLoss"
更适合.通常"SoftmaxWithLoss"
使用.
对于预测二进制输出,您也可以考虑"SigmoidCrossEntropyLoss"
.
"Accuracy"
图层中有错误?在caffe中," Accuracy"
层需要两个输入("底部"):一个是预测向量,另一个是基本事实预期的离散标签.在您的情况下,您需要为每个二进制输出提供长度为2的向量预测概率为0和1,以及单个二进制标签:
layer { name: "acc01" type: "Accuracy" bottom: "predict01" bottom: "label01" top: "acc01" }
在此示例中,您可以测量单个二进制输出的精度."predict01"
对于批处理中的每个示例,输入是双向量(对于batch_size: 50
此blob的形状应为50乘2).
您试图在单个网络中预测4 种不同的输出,因此,您需要4 种不同的损耗和精度层.
首先,您需要"Slice"
将地面实况标签拆分为4个标量(而不是单个二进制4向量):
layer { name: "label_split" bottom: "label" # name of input 4-vector top: "label01" top: "label02" top: "label03" top: "label04" type: "Slice" slice_param { axis: 1 slice_point: 1 slice_point: 2 slice_point: 3 } }
现在,您必须为每个二进制标签设置预测,丢失和准确度层
layer { name: "predict01" type: "InnerProduct" bottom: "sig2" top: "predict01" inner_product_param { num_outout: 2 # because you need to predict 2 probabilities one for False, one for True ... } layer { name: "loss01" type: "SoftmaxWithLoss" bottom: "predict01" bottom: "label01" top: "loss01" } layer { name: "acc01" type: "Accuracy" bottom: "predict01" bottom: "label01" top: "acc01" }
现在,您需要为要预测的四个二进制标签中的每一个复制这三个图层.