Skip to content

Commit

Permalink
Merge pull request BVLC#83 from thatguymike/divide_batch_by_solvers
Browse files Browse the repository at this point in the history
Fix gradient test to handle batch size correctly now that we divide
  • Loading branch information
thatguymike committed Nov 21, 2015
2 parents 3bfc708 + 35d07ea commit 49f752d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/caffe/test/test_gradient_based_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,8 @@ class GradientBasedSolverTest : public MultiDeviceTest<TypeParam> {
void TestLeastSquaresUpdate(const Dtype learning_rate = 1.0,
const Dtype weight_decay = 0.0, const Dtype momentum = 0.0,
const int iter_to_check = 0) {
const int kNum = num_;
const int kIterSize = 1;
const int kNum = num_;
// Test over all numbers of devices.
int available_devices = 1;
#ifndef CPU_ONLY
Expand All @@ -479,7 +479,7 @@ class GradientBasedSolverTest : public MultiDeviceTest<TypeParam> {
for (int devices = 1; devices <= available_devices; ++devices) {
// Configure batch size for single / multi device equivalence.
// Constant data is needed for multi device as for accumulation.
num_ = kNum * devices;
num_ = kNum * devices * devices;

// Initialize the solver and run K (= iter_to_check) solver iterations
// (on single device).
Expand All @@ -492,12 +492,15 @@ class GradientBasedSolverTest : public MultiDeviceTest<TypeParam> {
iter_to_check + 1, &updated_params);

// Reinitialize the solver and run K+1 solver iterations.
num_ = kNum;
num_ = kNum * devices;
RunLeastSquaresSolver(learning_rate, weight_decay, momentum,
iter_to_check + 1, kIterSize, devices);

// Check that the solver's solution matches ours.
CheckLeastSquaresUpdate(updated_params);

// Reset initial value of num_
num_ = kNum;
}
}

Expand Down

0 comments on commit 49f752d

Please sign in to comment.