Skip to content

Commit

Permalink
Re-added solver switch into the new caffe main excutable; fixed AdaGr…
Browse files Browse the repository at this point in the history
…ad MNIST example
  • Loading branch information
qipeng authored and jeffdonahue committed Sep 1, 2014
1 parent 06f335f commit a464df4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
1 change: 0 additions & 1 deletion examples/mnist/mnist_autoencoder_solver_adagrad.prototxt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ max_iter: 4000000
weight_decay: 0.0005
snapshot: 10000
snapshot_prefix: "mnist_autoencoder_train"
momentum: 0.9
# solver mode: CPU or GPU
solver_mode: GPU
solver_type: ADAGRAD
2 changes: 1 addition & 1 deletion examples/mnist/train_mnist_autoencoder_adagrad.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash
TOOLS=../../build/tools

$TOOLS/caffe.bin train --solver=mnist_autoencoder_solver.prototxt
$TOOLS/caffe.bin train --solver=mnist_autoencoder_solver_adagrad.prototxt
10 changes: 5 additions & 5 deletions tools/caffe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ int train() {
caffe::ReadProtoFromTextFileOrDie(FLAGS_solver, &solver_param);

LOG(INFO) << "Starting Optimization";
caffe::SGDSolver<float> solver(solver_param);
shared_ptr<caffe::Solver<float>> solver(caffe::GetSolver<float>(solver_param));

// Set device id and mode
if (FLAGS_gpu >= 0) {
Expand All @@ -102,13 +102,13 @@ int train() {

if (FLAGS_snapshot.size()) {
LOG(INFO) << "Resuming from " << FLAGS_snapshot;
solver.Solve(FLAGS_snapshot);
solver->Solve(FLAGS_snapshot);
} else if (FLAGS_weights.size()) {
LOG(INFO) << "Finetuning from " << FLAGS_weights;
solver.net()->CopyTrainedLayersFrom(FLAGS_weights);
solver.Solve();
solver->net()->CopyTrainedLayersFrom(FLAGS_weights);
solver->Solve();
} else {
solver.Solve();
solver->Solve();
}
LOG(INFO) << "Optimization Done.";
return 0;
Expand Down

0 comments on commit a464df4

Please sign in to comment.