Check failed: axis

xiaoxiao2021-02-28  108

这两周在做跨年龄的人脸识别。我用的是两个网络共同训练。有点像孪生网络(网络的浅层共享参数,深层用正交子空间,提取判别特征)。

在运行的时候爆出题目一样的error

Check failed: axis_index < num_axes() (1 vs. 1) axis 1 out of range for 1-D Blob with shape * *** Check failure stack trace: ***

思考了好久,也从开始追踪代码。看log。并没有什么异常。然后在log中发现如下信息:

Top shape: 128 3 112 96 (4128768) Top shape: 128 (128) #label Creating layer conv1a_age conv1a_age <- data_age #image ->blob as input for conv_layer conv1a_age -> conv1a_age Check failed: axis_index < num_axes() (1 vs. 1) axis 1 blob.hpp:122] out of range for 1-D Blob with shape 128 (128) #然后翻开Blob.hpp 查看源码,发现就是一个比较 ---------------------Blob.hpp line 122 function------------------------- inline int CanonicalAxisIndex(int axis_index) const { CHECK_GE(axis_index, -num_axes()) ┊ << "axis " << axis_index << " out of range for " << num_axes() ┊ << "-D Blob with shape " << shape_string(); CHECK_LT(axis_index, num_axes()) ┊ << "axis " << axis_index << " out of range for " << num_axes() ┊ << "-D Blob with shape " << shape_string(); if (axis_index < 0) { ┊ return axis_index + num_axes(); } return axis_index; } #原来是索引超出维度,在联系log中的信息,可不是嘛,索引必须<1,而现在给出的索引为1。 #那查看了一下输入:为了构建卷积层 ,输入 本应该是数据Top shape: 128 3 112 96 (4128768), #然后所以轴是1应该是正确的,但是读出来的shape_string 却是128 [Note:128是batchsize]。 #128应该是label对应的shape_string,因此很可能是label与data写反了。

再将目光转到train_test.prototxt 中。发现确实是先写的label后写的data【这纯粹是为了当初可视化网络的需要,没想到到后面遇到坑】。 【解决】将二者位置对调即可。

Check failed: status == CUBLAS_STATUS_SUCCESS (1 vs. 0) CUBLAS_STATUS_NOT_INITIALIZED 【解决方案】:检查你的caffe编译cuda库的版本与链接库的版本可能不一致。 很有可能是你用一个版本的编译,然后用另外一个版本连接。 在Makefile.config中的
转载请注明原文地址: https://www.6miu.com/read-32528.html

最新回复(0)