1
Caffe으로 시작하여 잘 실행했습니다.

inner product layer에 가중치를 적용해야합니다. Forward_cpu 함수는 weight을 표현하지만이 함수를 제곱하는 법을 모르겠습니다. 내가 caffe_sqr를 사용카페에서 내부 제품 레이어의 가중치를 정하는 방법은 무엇입니까?

template <typename Dtype> 
void InnerProductLayer<Dtype>::Forward_cpu(const vector<Blob<Dtype>*>& bottom, 
    const vector<Blob<Dtype>*>& top) { 
    const Dtype* bottom_data = bottom[0]->cpu_data(); 
    Dtype* top_data = top[0]->mutable_cpu_data(); 
    const Dtype* weight = this->blobs_[0]->cpu_data(); 
    Dtype* sqr_weight; 
    caffe_sqr<Dtype>(this->blobs_[0]->count(), weight, sqr_weight); 
    caffe_cpu_gemm<Dtype>(CblasNoTrans, transpose_ ? CblasNoTrans : CblasTrans, 
     M_, N_, K_, (Dtype)1., 
     bottom_data, weight, (Dtype)0., top_data); 
    if (bias_term_) { 
    caffe_cpu_gemm<Dtype>(CblasNoTrans, CblasNoTrans, M_, N_, 1, (Dtype)1., 
     bias_multiplier_.cpu_data(), 
     this->blobs_[1]->cpu_data(), (Dtype)1., top_data); 
    } 
} 

참고 있지만, 오류가 caffe_sqr<Dtype>(weight.count(), weights, new_weights); 반환 forward_cpu 기능은 다음과 같이 정의된다.

warning: ‘sqr_weight’ is used uninitialized in this function [-Wuninitialized] 
caffe_sqr<Dtype>(this->blobs_[0]->count(), weight, sqr_weight); 

내 모델을 훈련 후, 오류는 다음과 같습니다 : 난 내 새 레이어를 만들 때, 경고는

F1229 20:00:38.622575 5272 mkl_alternate.hpp:34] Check failed: y 
Check failure stack trace: 
@  0x7f4f97e675cd google::LogMessage::Fail() 
@  0x7f4f97e69433 google::LogMessage::SendToLog() 
@  0x7f4f97e6715b google::LogMessage::Flush() 
@  0x7f4f97e69e1e google::LogMessageFatal::~LogMessageFatal() 
@  0x7f4f98338760 vSqr<>() 
@  0x7f4f982eb45a caffe::PositiveInnerProductLayer<>::Forward_cpu() 
@  0x7f4f9830b0d3 caffe::Net<>::ForwardFromTo() 
@  0x7f4f9830b347 caffe::Net<>::ForwardPrefilled() 
@  0x7f4f981e075f caffe::Solver<>::Test() 
@  0x7f4f981e119e caffe::Solver<>::TestAll() 
@  0x7f4f981e12eb caffe::Solver<>::Step() 
@  0x7f4f981e1f85 caffe::Solver<>::Solve() 
@   0x40aafb train() 
@   0x406f48 main 
@  0x7f4f970f6830 __libc_start_main 
@   0x407609 _start 
@    (nil) (unknown) 
많은 감사합니다 !!!! 모든 조언을 부탁드립니다!

답변

1

Dtype에 대한 포인터로 정의되고 포인터에는 count() 메서드가 없음을 유의하십시오.

당신은 체중 방울의 count() 필요

this->blobs_[0]->count() 
+0

친애하는 @shai, 정말 고마워요 당신의 시간을,하지만 어떻게 가중치를 정사각형으로?! –

+0

@ahmadnavidghanizadeh'caffe_sqr '의 문제점은 무엇입니까? – Shai

+0

나는 질문을 편집한다. 주목 해 주셔서 감사합니다. –

관련 문제