dlib 19.13-Linux Mint 18 g ++(Ubuntu 5.4.0-6ubuntu1〜16.04.9)5.4.0 20160609
尝试使用以下代码段与dlib进行XOR NN:
...
std::vector<matrix<unsigned long>> training_set;
std::vector<unsigned long> training_labels;
std::vector<matrix<unsigned long>> testing_set;
std::vector<unsigned long> testing_labels;
training_set.push_back( {0,0} );
training_set.push_back( {0,1} );
training_set.push_back( {1,0} );
training_set.push_back( {1,1} );
training_labels.push_back(0);
training_labels.push_back(1);
training_labels.push_back(1);
training_labels.push_back(0);
testing_set.push_back( {0,0} );
testing_set.push_back( {0,1} );
testing_set.push_back( {1,0} );
testing_set.push_back( {1,1} );
testing_labels.push_back(0);
testing_labels.push_back(1);
testing_labels.push_back(1);
testing_labels.push_back(0);
using net_type = loss_multiclass_log<
fc<1,
relu<fc<3,
input<matrix<unsigned long>>
>>>>;
...
它可以编译,但是我在执行测试时得到以下输出:
在第322行检测到错误。 在文件../dlib/dnn/loss.h中检测到错误。 在函数double dlib :: loss_multiclass_log _ :: compute_loss_value_and_gradient(const dlib :: tensor&,const_label_iterator,SUBNET&)中检测到错误const [with const_label_iterator = __gnu_cxx :: __ normal_iterator>; SUBNET = dlib :: dimpl :: subnet_wrapper,dlib :: add_layer,dlib :: input>,void>,void>,void>,true,void>]。
失败的表达式是y
答案 0 :(得分:1)
我认为dlib的fc类的第一个参数是输出节点的数量。但事实证明,这似乎是可能的产出数量。因此0和1是该层的两个可能的输出值。从1更改为2,然后重新编译网络火车,并显示出100%的准确性:
using net_type = loss_multiclass_log<
fc<2, // <--- changed to 2
relu<fc<3,
input<matrix<unsigned long>>
>>>>;