如何在caffe Forward_gpu期间打印变量
How to print variables during Forward_gpu in caffe
我试图在 Forward_gpu 函数中打印底部形状和底部数据。但是会造成段错误。有人可以告诉我这样做的正确方法以及出现段错误的原因吗?
我做到了:
void Forward_gpu(const vector<Blob<Dtype> *> &bottom, const vector<Blob<Dtype> *> &top)
{
...
puts("bottom shape: ");
std::cout << bottom[2*i]->gpu_shape()[0] << std::endl;
...
}
我得到的:
bottom shape:
*** Aborted at 1500362213 (unix time) try "date -d @1500362213" if you are using GNU date ***
PC: @ 0x7fe4be27cbfd caffe::DeformableConvolutionLayer<>::Forward_gpu()
*** SIGSEGV (@0x1020d602c00) received by PID 17153 (TID 0x7fe4bea969c0) from PID 224406528; stack trace: ***
@ 0x7fe4bc615cb0 (unknown)
@ 0x7fe4be27cbfd caffe::DeformableConvolutionLayer<>::Forward_gpu()
@ 0x7fe4be204471 caffe::Net<>::ForwardFromTo()
@ 0x7fe4be2047e7 caffe::Net<>::ForwardPrefilled()
@ 0x7fe4be224455 caffe::Solver<>::Step()
@ 0x7fe4be224d59 caffe::Solver<>::Solve()
@ 0x4084be train()
@ 0x405cac main
@ 0x7fe4bc600f45 (unknown)
@ 0x40647d (unknown)
@ 0x0 (unknown)
Segmentation fault (core dumped)
你必须像这样访问它们
bottom[2*i]->shape(0)
并确保 2*i 在可用底部范围内,首先尝试
bottom[0]->shape(0)
确保至少可以打印出来
我试图在 Forward_gpu 函数中打印底部形状和底部数据。但是会造成段错误。有人可以告诉我这样做的正确方法以及出现段错误的原因吗?
我做到了:
void Forward_gpu(const vector<Blob<Dtype> *> &bottom, const vector<Blob<Dtype> *> &top)
{
...
puts("bottom shape: ");
std::cout << bottom[2*i]->gpu_shape()[0] << std::endl;
...
}
我得到的:
bottom shape:
*** Aborted at 1500362213 (unix time) try "date -d @1500362213" if you are using GNU date ***
PC: @ 0x7fe4be27cbfd caffe::DeformableConvolutionLayer<>::Forward_gpu()
*** SIGSEGV (@0x1020d602c00) received by PID 17153 (TID 0x7fe4bea969c0) from PID 224406528; stack trace: ***
@ 0x7fe4bc615cb0 (unknown)
@ 0x7fe4be27cbfd caffe::DeformableConvolutionLayer<>::Forward_gpu()
@ 0x7fe4be204471 caffe::Net<>::ForwardFromTo()
@ 0x7fe4be2047e7 caffe::Net<>::ForwardPrefilled()
@ 0x7fe4be224455 caffe::Solver<>::Step()
@ 0x7fe4be224d59 caffe::Solver<>::Solve()
@ 0x4084be train()
@ 0x405cac main
@ 0x7fe4bc600f45 (unknown)
@ 0x40647d (unknown)
@ 0x0 (unknown)
Segmentation fault (core dumped)
你必须像这样访问它们
bottom[2*i]->shape(0)
并确保 2*i 在可用底部范围内,首先尝试
bottom[0]->shape(0)
确保至少可以打印出来