Skip to content

Commit c840119

Browse files
committed
dropout serious bugfix. Seems to be working...
1 parent e1af72e commit c840119

File tree

5 files changed

+10
-10
lines changed

5 files changed

+10
-10
lines changed

src/caffe/layers/dropout_layer.cu

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,7 @@ __global__ void DropoutBackward(const int n, const Dtype* in_diff,
9797
Dtype* out_diff) {
9898
int index = threadIdx.x + blockIdx.x * blockDim.x;
9999
if (index < n) {
100-
if (mask[index] > threshold) {
101-
out_diff[index] = in_diff[index] * scale;
102-
}
100+
out_diff[index] = in_diff[index] * scale * (mask[index] > threshold);
103101
}
104102
}
105103

src/caffe/proto/caffe.proto

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ message Datum {
2323
}
2424

2525
message FillerParameter {
26-
// The filler type. In default we will set it to Gaussian for easy
27-
// debugging.
28-
optional string type = 1 [default = 'gaussian'];
26+
// The filler type.
27+
optional string type = 1 [default = 'constant'];
2928
optional float value = 2 [default = 0]; // the value in constant filler
3029
optional float min = 3 [default = 0]; // the min value in uniform filler
3130
optional float max = 4 [default = 1]; // the max value in uniform filler

src/caffe/test/test_protobuf.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,4 @@ TEST_F(ProtoTest, TestSerialization) {
2626
EXPECT_TRUE(true);
2727
}
2828

29-
3029
}

src/programs/demo_mnist.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ using namespace caffe;
1919
int main(int argc, char** argv) {
2020
cudaSetDevice(0);
2121
Caffe::set_mode(Caffe::GPU);
22+
Caffe::set_phase(Caffe::TRAIN);
2223

2324
NetParameter net_param;
2425
ReadProtoFromTextFile("data/lenet.prototxt",
@@ -34,7 +35,7 @@ int main(int argc, char** argv) {
3435

3536
SolverParameter solver_param;
3637
solver_param.set_base_lr(0.01);
37-
solver_param.set_display(0);
38+
solver_param.set_display(1);
3839
solver_param.set_max_iter(6000);
3940
solver_param.set_lr_policy("inv");
4041
solver_param.set_gamma(0.0001);
@@ -63,6 +64,8 @@ int main(int argc, char** argv) {
6364
Net<float> caffe_traintest_net(traintest_net_param, bottom_vec);
6465
caffe_traintest_net.CopyTrainedLayersFrom(trained_net_param);
6566

67+
Caffe::set_phase(Caffe::TEST);
68+
6669
// Test run
6770
double train_accuracy = 0;
6871
int batch_size = traintest_net_param.layers(0).layer().batchsize();

src/programs/train_alexnet.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ using namespace caffe;
1919
int main(int argc, char** argv) {
2020
cudaSetDevice(0);
2121
Caffe::set_mode(Caffe::GPU);
22+
Caffe::set_phase(Caffe::TRAIN);
2223

2324
NetParameter net_param;
2425
ReadProtoFromTextFile(argv[1],
@@ -49,11 +50,11 @@ int main(int argc, char** argv) {
4950
SolverParameter solver_param;
5051
solver_param.set_base_lr(0.01);
5152
solver_param.set_display(1);
52-
solver_param.set_max_iter(2);
53+
solver_param.set_max_iter(60000);
5354
solver_param.set_lr_policy("fixed");
5455
solver_param.set_momentum(0.9);
5556
solver_param.set_weight_decay(0.0005);
56-
solver_param.set_snapshot(1);
57+
solver_param.set_snapshot(5000);
5758
solver_param.set_snapshot_prefix("alexnet");
5859

5960
LOG(ERROR) << "Starting Optimization";

0 commit comments

Comments
 (0)