Skip to content

Commit

Permalink
fixed two bugs with prototext format
Browse files Browse the repository at this point in the history
The first bug was in InitUnsharedWeightsNet. Proto var was of type
ostringstream, which converted the bool bias_term into an int. I
wrote an inline conditional to convert the term into a string.
This allows backwards compatibility with earlier prototext
versions (e.g. version 2.3.0 on Redhat was failing without this).

The second bug was in the syntax for repeated bool parameters,
assigned to the propagate_down parameter. The style used for e.g.
propagate_down: [true,true] does not work with earlier prototext
versions (failed with version 2.3.0 on Redhat). New syntax works
for all versions.
  • Loading branch information
Dylan Paiton committed Jun 17, 2015
1 parent 0d7c6cb commit 98fb438
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/caffe/test/test_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ class NetTest : public MultiDeviceTest<TypeParam> {
const bool force_backward = false, const bool bias_term = false,
const Dtype blobs_lr_w1 = 1, const Dtype blobs_lr_b1 = 2,
const Dtype blobs_lr_w2 = 1, const Dtype blobs_lr_b2 = 2) {
string bias_str = bias_term ? "true ":"false ";
ostringstream proto;
proto << "name: 'UnsharedWeightsNetwork' ";
if (force_backward) {
Expand All @@ -314,7 +315,7 @@ class NetTest : public MultiDeviceTest<TypeParam> {
" type: 'InnerProduct' "
" inner_product_param { "
" num_output: 10 "
" bias_term: " << bias_term <<
" bias_term: " << bias_str <<
" weight_filler { "
" type: 'gaussian' "
" std: 10 "
Expand All @@ -340,7 +341,7 @@ class NetTest : public MultiDeviceTest<TypeParam> {
" type: 'InnerProduct' "
" inner_product_param { "
" num_output: 10 "
" bias_term: " << bias_term <<
" bias_term: " << bias_str <<
" weight_filler { "
" type: 'gaussian' "
" std: 10 "
Expand Down Expand Up @@ -699,9 +700,11 @@ class NetTest : public MultiDeviceTest<TypeParam> {
" bottom: 'innerproduct' "
" bottom: 'label_argmax' ";
if (test_skip_true)
proto += " propagate_down: [true, false] ";
proto += " propagate_down: true "
" propagate_down: false ";
else
proto += " propagate_down: [true, true] ";
proto += " propagate_down: true "
" propagate_down: true ";
proto +=
" top: 'cross_entropy_loss' "
" type: 'SigmoidCrossEntropyLoss' "
Expand Down

0 comments on commit 98fb438

Please sign in to comment.