2016-07-01 8 views
3

Ich baue meine Caffe mit DEBUG=1 Flagge. daher konnte ich es mit gdb debuggen.caffe: wie auf die Daten in BLOB mit gdb zugreifen?

meine Debug-Programme war das mnist Beispiel:

gdb --args .build_debug/tools/caffe train --solver=examples/mnist/lenet_solver.prototxt 

ich

./include/caffe/layer.hpp:451

meine Pause Punkt gesetzt

was der Funktion entspricht:

inline Dtype Layer<Dtype>::Forward(const vector<Blob<Dtype>*>& bottom, 
const vector<Blob<Dtype>*>& top) 

Ich habe versucht, die DATEN dieses BLOB zu drucken, aber ich finde nicht meinen Weg.

was kann ich bekommen ist:

  • unten und oben sind Vektor vvectors.
(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> 
  • ich die Meta-Daten dieses 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 
} 

aber ich scheiterte, um die Daten zu bekommen finden. das einzige, was ich tun kann, ist

(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 
} 

Wie kann ich die data_ und diff_ Mitglied dieser Blob drucken?

Antwort

2

Zum Beispiel:

(gdb) p *((float *)(bottom[1].data_.px)->cpu_ptr_+0)

$15 = 0 

oder

(gdb) p *((float *)(bottom[1].data_.px)->cpu_ptr_+1)

$16 = 1 

Und auch benötigt eszu ersetzenzu Ihrem tatsächlichen Blob-Zeigertyp.

Verwandte Themen