From a123130cb3d9d7dd09875d29beffd8c37249f2c5 Mon Sep 17 00:00:00 2001 From: Jeff Donahue Date: Fri, 21 Mar 2014 13:05:59 -0700 Subject: [PATCH] loss in forward pass fix for window data layer --- include/caffe/vision_layers.hpp | 12 ++++++------ src/caffe/layers/window_data_layer.cpp | 17 +++-------------- 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/include/caffe/vision_layers.hpp b/include/caffe/vision_layers.hpp index 2c471fa..91a2324 100644 --- a/include/caffe/vision_layers.hpp +++ b/include/caffe/vision_layers.hpp @@ -637,14 +637,14 @@ class WindowDataLayer : public Layer { vector*>* top); protected: - virtual void Forward_cpu(const vector*>& bottom, + virtual Dtype Forward_cpu(const vector*>& bottom, vector*>* top); - virtual void Forward_gpu(const vector*>& bottom, + virtual Dtype Forward_gpu(const vector*>& bottom, vector*>* top); - virtual Dtype Backward_cpu(const vector*>& top, - const bool propagate_down, vector*>* bottom); - virtual Dtype Backward_gpu(const vector*>& top, - const bool propagate_down, vector*>* bottom); + virtual void Backward_cpu(const vector*>& top, + const bool propagate_down, vector*>* bottom) { return; } + virtual void Backward_gpu(const vector*>& top, + const bool propagate_down, vector*>* bottom) { return; } pthread_t thread_; shared_ptr > prefetch_data_; diff --git a/src/caffe/layers/window_data_layer.cpp b/src/caffe/layers/window_data_layer.cpp index 87fb541..a288403 100644 --- a/src/caffe/layers/window_data_layer.cpp +++ b/src/caffe/layers/window_data_layer.cpp @@ -403,7 +403,7 @@ void WindowDataLayer::SetUp(const vector*>& bottom, } template -void WindowDataLayer::Forward_cpu(const vector*>& bottom, +Dtype WindowDataLayer::Forward_cpu(const vector*>& bottom, vector*>* top) { // First, join the thread CHECK(!pthread_join(thread_, NULL)) << "Pthread joining failed."; @@ -415,10 +415,11 @@ void WindowDataLayer::Forward_cpu(const vector*>& bottom, // Start a new prefetch thread CHECK(!pthread_create(&thread_, NULL, WindowDataLayerPrefetch, reinterpret_cast(this))) << "Pthread execution failed."; + return Dtype(0.); } template -void WindowDataLayer::Forward_gpu(const vector*>& bottom, +Dtype WindowDataLayer::Forward_gpu(const vector*>& bottom, vector*>* top) { // First, join the thread CHECK(!pthread_join(thread_, NULL)) << "Pthread joining failed."; @@ -432,18 +433,6 @@ void WindowDataLayer::Forward_gpu(const vector*>& bottom, // Start a new prefetch thread CHECK(!pthread_create(&thread_, NULL, WindowDataLayerPrefetch, reinterpret_cast(this))) << "Pthread execution failed."; -} - -// The backward operations are dummy - they do not carry any computation. -template -Dtype WindowDataLayer::Backward_cpu(const vector*>& top, - const bool propagate_down, vector*>* bottom) { - return Dtype(0.); -} - -template -Dtype WindowDataLayer::Backward_gpu(const vector*>& top, - const bool propagate_down, vector*>* bottom) { return Dtype(0.); } -- 2.7.4