GeezerVison is showing github.com — Merge pull request #19 from lisa-lab/fix_iter_index · imclab/DeepLearningTutorials@61c1dda
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: code/DBN.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -359,7 +359,7 @@ def test_DBN(finetune_lr=0.1, pretraining_epochs=100, | 359 | 359 | for minibatch_index in xrange(n_train_batches): | 360 | 360 |
| 361 | 361 | minibatch_avg_cost = train_fn(minibatch_index) | 362 | | - iter = epoch * n_train_batches + minibatch_index | | 362 | + iter = (epoch - 1) * n_train_batches + minibatch_index | 363 | 363 |
| 364 | 364 | if (iter + 1) % validation_frequency == 0: | 365 | 365 |
| |
Collapse file Copy file name to clipboardExpand all lines: code/SdA.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -395,9 +395,10 @@ def test_SdA(finetune_lr=0.1, pretraining_epochs=15, | 395 | 395 | epoch = 0 | 396 | 396 |
| 397 | 397 | while (epoch < training_epochs) and (not done_looping): | | 398 | + epoch = epoch + 1 | 398 | 399 | for minibatch_index in xrange(n_train_batches): | 399 | 400 | minibatch_avg_cost = train_fn(minibatch_index) | 400 | | - iter = epoch * n_train_batches + minibatch_index | | 401 | + iter = (epoch - 1) * n_train_batches + minibatch_index | 401 | 402 |
| 402 | 403 | if (iter + 1) % validation_frequency == 0: | 403 | 404 | validation_losses = validate_model() | @@ -429,7 +430,6 @@ def test_SdA(finetune_lr=0.1, pretraining_epochs=15, | 429 | 430 | if patience <= iter: | 430 | 431 | done_looping = True | 431 | 432 | break | 432 | | - epoch = epoch + 1 | 433 | 433 |
| 434 | 434 | end_time = time.clock() | 435 | 435 | print(('Optimization complete with best validation score of %f %%,' | |
Collapse file Copy file name to clipboardExpand all lines: code/convolutional_mlp.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -246,7 +246,7 @@ def evaluate_lenet5(learning_rate=0.1, n_epochs=200, | 246 | 246 | epoch = epoch + 1 | 247 | 247 | for minibatch_index in xrange(n_train_batches): | 248 | 248 |
| 249 | | - iter = epoch * n_train_batches + minibatch_index | | 249 | + iter = (epoch - 1) * n_train_batches + minibatch_index | 250 | 250 |
| 251 | 251 | if iter % 100 == 0: | 252 | 252 | print 'training @ iter = ', iter | @@ -296,7 +296,7 @@ def evaluate_lenet5(learning_rate=0.1, n_epochs=200, | 296 | 296 | ' ran for %.2fm' % ((end_time - start_time) / 60.)) | 297 | 297 |
| 298 | 298 | if __name__ == '__main__': | 299 | | - evaluate_lenet5() | | 299 | + evaluate_lenet5(n_epochs=1, batch_size=1) | 300 | 300 |
| 301 | 301 |
| 302 | 302 | def experiment(state, channel): | |
Collapse file Copy file name to clipboardExpand all lines: code/logistic_sgd.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -323,7 +323,7 @@ def sgd_optimization_mnist(learning_rate=0.13, n_epochs=1000, | 323 | 323 |
| 324 | 324 | minibatch_avg_cost = train_model(minibatch_index) | 325 | 325 | # iteration number | 326 | | - iter = epoch * n_train_batches + minibatch_index | | 326 | + iter = (epoch - 1) * n_train_batches + minibatch_index | 327 | 327 |
| 328 | 328 | if (iter + 1) % validation_frequency == 0: | 329 | 329 | # compute zero-one loss on validation set | |
Collapse file Copy file name to clipboardExpand all lines: code/mlp.py +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -309,7 +309,7 @@ def test_mlp(learning_rate=0.01, L1_reg=0.00, L2_reg=0.0001, n_epochs=1000, | 309 | 309 |
| 310 | 310 | minibatch_avg_cost = train_model(minibatch_index) | 311 | 311 | # iteration number | 312 | | - iter = epoch * n_train_batches + minibatch_index | | 312 | + iter = (epoch - 1) * n_train_batches + minibatch_index | 313 | 313 |
| 314 | 314 | if (iter + 1) % validation_frequency == 0: | 315 | 315 | # compute zero-one loss on validation set | |
Collapse file Copy file name to clipboardExpand all lines: doc/gettingstarted.txt +6-4Lines changed: 6 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -576,17 +576,19 @@ of a strategy based on a geometrically increasing amount of patience. | 576 | 576 | done_looping = False | 577 | 577 | epoch = 0 | 578 | 578 | while (epoch < n_epochs) and (not done_looping): | | 579 | + # Report "1" for first epoch, "n_epochs" for last epoch | 579 | 580 | epoch = epoch + 1 | 580 | 581 | for minibatch_index in xrange(n_train_batches): | 581 | 582 |
| 582 | 583 | d_loss_wrt_params = ... # compute gradient | 583 | 584 | params -= learning_rate * d_loss_wrt_params # gradient descent | 584 | 585 |
| 585 | | - # iteration number | 586 | | - iter = epoch * n_train_batches + minibatch_index | | 586 | + # iteration number. We want it to start at 0. | | 587 | + iter = (epoch - 1) * n_train_batches + minibatch_index | 587 | 588 | # note that if we do `iter % validation_frequency` it will be | 588 | | - # true for iter = 0 which we do not want | 589 | | - if iter and iter % validation_frequency == 0: | | 589 | + # true for iter = 0 which we do not want. We want it true for | | 590 | + # iter = validation_frequency - 1. | | 591 | + if (iter + 1) % validation_frequency == 0: | 590 | 592 |
| 591 | 593 | this_validation_loss = ... # compute zero-one loss on validation set | 592 | 594 |
| |
Collapse file Copy file name to clipboardExpand all lines: doc/logreg.txt +5-5Lines changed: 5 additions & 5 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -396,12 +396,12 @@ The output one should expect is of the form : | 396 | 396 | .. code-block:: bash | 397 | 397 |
| 398 | 398 | ... | | 399 | + epoch 72, minibatch 83/83, validation error 7.510417 % | | 400 | + epoch 72, minibatch 83/83, test error of best model 7.510417 % | 399 | 401 | epoch 73, minibatch 83/83, validation error 7.500000 % | 400 | | - epoch 73, minibatch 83/83, test error of best model 7.489583 % | 401 | | - epoch 74, minibatch 83/83, validation error 7.479167 % | 402 | | - epoch 74, minibatch 83/83, test error of best model 7.489583 % | 403 | | - Optimization complete with best validation score of 7.479167 %,with test performance 7.489583 % | 404 | | - The code run for 75 epochs, with 1.936983 epochs/sec | | 402 | + epoch 73, minibatch 83/83, test error of best model 7.489583 % | | 403 | + Optimization complete with best validation score of 7.500000 %,with test performance 7.489583 % | | 404 | + The code run for 74 epochs, with 1.936983 epochs/sec | 405 | 405 |
| 406 | 406 |
| 407 | 407 | On an Intel(R) Core(TM)2 Duo CPU E8400 @ 3.00 Ghz the code runs with | |
|