summaryrefslogtreecommitdiff
path: root/src/caffe/net.cpp
diff options
context:
space:
mode:
authorJeff Donahue <jeff.donahue@gmail.com>2014-03-15 12:22:53 -0700
committerJeff Donahue <jeff.donahue@gmail.com>2014-03-19 12:37:31 -0700
commit0551d93831ef3a293efae0ab474f459d09779aa8 (patch)
tree72e855186b575bd6a2289d902291aa48ee17f0b5 /src/caffe/net.cpp
parent44fbb82f477039bc3038b53fccec29a48a9c4a0c (diff)
downloadcaffeonacl-0551d93831ef3a293efae0ab474f459d09779aa8.tar.gz
caffeonacl-0551d93831ef3a293efae0ab474f459d09779aa8.tar.bz2
caffeonacl-0551d93831ef3a293efae0ab474f459d09779aa8.zip
null pointer defaults for forward loss outputs
Diffstat (limited to 'src/caffe/net.cpp')
-rw-r--r--src/caffe/net.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/caffe/net.cpp b/src/caffe/net.cpp
index 397ee02b..f3429b22 100644
--- a/src/caffe/net.cpp
+++ b/src/caffe/net.cpp
@@ -207,30 +207,22 @@ void Net<Dtype>::GetLearningRateAndWeightDecay() {
}
template <typename Dtype>
-const vector<Blob<Dtype>*>& Net<Dtype>::ForwardPrefilled() {
- Dtype ignored_loss;
- return ForwardPrefilled(&ignored_loss);
-}
-
-template <typename Dtype>
const vector<Blob<Dtype>*>& Net<Dtype>::ForwardPrefilled(Dtype* loss) {
- *loss = Dtype(0.);
+ if (loss != NULL) {
+ *loss = Dtype(0.);
+ }
for (int i = 0; i < layers_.size(); ++i) {
// LOG(ERROR) << "Forwarding " << layer_names_[i];
- *loss += layers_[i]->Forward(bottom_vecs_[i], &top_vecs_[i]);
+ Dtype layer_loss = layers_[i]->Forward(bottom_vecs_[i], &top_vecs_[i]);
+ if (loss != NULL) {
+ *loss += layer_loss;
+ }
}
return net_output_blobs_;
}
template <typename Dtype>
const vector<Blob<Dtype>*>& Net<Dtype>::Forward(
- const vector<Blob<Dtype>*> & bottom) {
- Dtype ignored_loss;
- return Forward(bottom, &ignored_loss);
-}
-
-template <typename Dtype>
-const vector<Blob<Dtype>*>& Net<Dtype>::Forward(
const vector<Blob<Dtype>*> & bottom, Dtype* loss) {
// Copy bottom to internal bottom
for (int i = 0; i < bottom.size(); ++i) {