我使用DEBUG=1
标志构建我的caffe。因此,我可以使用gdb进行调试。
我的调试程序是mnist示例:
gdb --args .build_debug/tools/caffe train --solver=examples/mnist/lenet_solver.prototxt
我在
./include/caffe/layer.hpp:451
设置了断点,该行对应的函数是:
inline Dtype Layer<Dtype>::Forward(const vector<Blob<Dtype>*>& bottom,
const vector<Blob<Dtype>*>& top)
我试图打印出这个BLOB的数据,但找不到方法。
我能得到的是:
bottom和top是向量的向量。
(gdb) p bottom
$30 = std::vector of length 2, capacity 2 = {0x4c24300, 0x4b12fd0}
(gdb) what bottom
type = const std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> > &
(gdb) what bottom[0]
type = std::vector<caffe::Blob<float>*, std::allocator<caffe::Blob<float>*> >::reference
(gdb) what bottom[0][0]
type = caffe::Blob<float>
我可以找到这个blob的元数据。
(gdb) p bottom[0][0]
$42 = {
data_ = {
px = 0x4c23710,
pn = {
pi_ = 0x4c23740
}
},
diff_ = {
px = 0x4c23fc0,
pn = {
pi_ = 0x4c23ff0
}
},
shape_data_ = {
px = 0x4c23f00,
pn = {
pi_ = 0x4c23f30
}
},
shape_ = std::vector of length 2, capacity 2 = {100, 10},
count_ = 1000,
capacity_ = 1000
}
但是我未能获取数据。我唯一能做的就是:
(gdb) p bottom[0][0].data_
$43 = {
px = 0x4c23710,
pn = {
pi_ = 0x4c23740
}
}
(gdb) p bottom[0][0].data_.px[0]
$44 = {
cpu_ptr_ = 0x474fef0,
gpu_ptr_ = 0x0,
size_ = 4000,
head_ = caffe::SyncedMemory::HEAD_AT_CPU,
own_cpu_data_ = true,
cpu_malloc_use_cuda_ = false,
own_gpu_data_ = false,
gpu_device_ = -1
}
我如何打印此Blob的data_和diff_成员?