Skip to content

Commit

Permalink
dropout serious bugfix. Seems to be working...
Browse files Browse the repository at this point in the history
  • Loading branch information
Yangqing committed Oct 10, 2013
1 parent e1af72e commit c840119
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
4 changes: 1 addition & 3 deletions src/caffe/layers/dropout_layer.cu
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,7 @@ __global__ void DropoutBackward(const int n, const Dtype* in_diff,
Dtype* out_diff) {
int index = threadIdx.x + blockIdx.x * blockDim.x;
if (index < n) {
if (mask[index] > threshold) {
out_diff[index] = in_diff[index] * scale;
}
out_diff[index] = in_diff[index] * scale * (mask[index] > threshold);
}
}

Expand Down
5 changes: 2 additions & 3 deletions src/caffe/proto/caffe.proto
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ message Datum {
}

message FillerParameter {
// The filler type. In default we will set it to Gaussian for easy
// debugging.
optional string type = 1 [default = 'gaussian'];
// The filler type.
optional string type = 1 [default = 'constant'];
optional float value = 2 [default = 0]; // the value in constant filler
optional float min = 3 [default = 0]; // the min value in uniform filler
optional float max = 4 [default = 1]; // the max value in uniform filler
Expand Down
1 change: 0 additions & 1 deletion src/caffe/test/test_protobuf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,4 @@ TEST_F(ProtoTest, TestSerialization) {
EXPECT_TRUE(true);
}


}
5 changes: 4 additions & 1 deletion src/programs/demo_mnist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ using namespace caffe;
int main(int argc, char** argv) {
cudaSetDevice(0);
Caffe::set_mode(Caffe::GPU);
Caffe::set_phase(Caffe::TRAIN);

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

SolverParameter solver_param;
solver_param.set_base_lr(0.01);
solver_param.set_display(0);
solver_param.set_display(1);
solver_param.set_max_iter(6000);
solver_param.set_lr_policy("inv");
solver_param.set_gamma(0.0001);
Expand Down Expand Up @@ -63,6 +64,8 @@ int main(int argc, char** argv) {
Net<float> caffe_traintest_net(traintest_net_param, bottom_vec);
caffe_traintest_net.CopyTrainedLayersFrom(trained_net_param);

Caffe::set_phase(Caffe::TEST);

// Test run
double train_accuracy = 0;
int batch_size = traintest_net_param.layers(0).layer().batchsize();
Expand Down
5 changes: 3 additions & 2 deletions src/programs/train_alexnet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ using namespace caffe;
int main(int argc, char** argv) {
cudaSetDevice(0);
Caffe::set_mode(Caffe::GPU);
Caffe::set_phase(Caffe::TRAIN);

NetParameter net_param;
ReadProtoFromTextFile(argv[1],
Expand Down Expand Up @@ -49,11 +50,11 @@ int main(int argc, char** argv) {
SolverParameter solver_param;
solver_param.set_base_lr(0.01);
solver_param.set_display(1);
solver_param.set_max_iter(2);
solver_param.set_max_iter(60000);
solver_param.set_lr_policy("fixed");
solver_param.set_momentum(0.9);
solver_param.set_weight_decay(0.0005);
solver_param.set_snapshot(1);
solver_param.set_snapshot(5000);
solver_param.set_snapshot_prefix("alexnet");

LOG(ERROR) << "Starting Optimization";
Expand Down

0 comments on commit c840119

Please sign in to comment.