GeezerVison is showing github.com — replace time.clock() by time.time() · willfu/DeepLearningTutorials@a8bde07
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 +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -327,7 +327,7 @@ def test_DBN(finetune_lr=0.1, pretraining_epochs=100, | 327 | 327 | k=k) | 328 | 328 |
| 329 | 329 | print '... pre-training the model' | 330 | | - start_time = time.clock() | | 330 | + start_time = time.time() | 331 | 331 | ## Pre-train layer-wise | 332 | 332 | for i in xrange(dbn.n_layers): | 333 | 333 | # go through pretraining epochs | @@ -340,7 +340,7 @@ def test_DBN(finetune_lr=0.1, pretraining_epochs=100, | 340 | 340 | print 'Pre-training layer %i, epoch %d, cost ' % (i, epoch), | 341 | 341 | print numpy.mean(c) | 342 | 342 |
| 343 | | - end_time = time.clock() | | 343 | + end_time = time.time() | 344 | 344 | # end-snippet-2 | 345 | 345 | print >> sys.stderr, ('The pretraining code for file ' + | 346 | 346 | os.path.split(__file__)[1] + | @@ -372,7 +372,7 @@ def test_DBN(finetune_lr=0.1, pretraining_epochs=100, | 372 | 372 |
| 373 | 373 | best_validation_loss = numpy.inf | 374 | 374 | test_score = 0. | 375 | | - start_time = time.clock() | | 375 | + start_time = time.time() | 376 | 376 |
| 377 | 377 | done_looping = False | 378 | 378 | epoch = 0 | @@ -424,7 +424,7 @@ def test_DBN(finetune_lr=0.1, pretraining_epochs=100, | 424 | 424 | done_looping = True | 425 | 425 | break | 426 | 426 |
| 427 | | - end_time = time.clock() | | 427 | + end_time = time.time() | 428 | 428 | print( | 429 | 429 | ( | 430 | 430 | 'Optimization complete with best validation score of %f %%, ' | |
Collapse file Copy file name to clipboardExpand all lines: code/SdA.py +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -379,7 +379,7 @@ def test_SdA(finetune_lr=0.1, pretraining_epochs=15, | 379 | 379 | batch_size=batch_size) | 380 | 380 |
| 381 | 381 | print '... pre-training the model' | 382 | | - start_time = time.clock() | | 382 | + start_time = time.time() | 383 | 383 | ## Pre-train layer-wise | 384 | 384 | corruption_levels = [.1, .2, .3] | 385 | 385 | for i in xrange(sda.n_layers): | @@ -394,7 +394,7 @@ def test_SdA(finetune_lr=0.1, pretraining_epochs=15, | 394 | 394 | print 'Pre-training layer %i, epoch %d, cost ' % (i, epoch), | 395 | 395 | print numpy.mean(c) | 396 | 396 |
| 397 | | - end_time = time.clock() | | 397 | + end_time = time.time() | 398 | 398 |
| 399 | 399 | print >> sys.stderr, ('The pretraining code for file ' + | 400 | 400 | os.path.split(__file__)[1] + | @@ -427,7 +427,7 @@ def test_SdA(finetune_lr=0.1, pretraining_epochs=15, | 427 | 427 |
| 428 | 428 | best_validation_loss = numpy.inf | 429 | 429 | test_score = 0. | 430 | | - start_time = time.clock() | | 430 | + start_time = time.time() | 431 | 431 |
| 432 | 432 | done_looping = False | 433 | 433 | epoch = 0 | @@ -471,7 +471,7 @@ def test_SdA(finetune_lr=0.1, pretraining_epochs=15, | 471 | 471 | done_looping = True | 472 | 472 | break | 473 | 473 |
| 474 | | - end_time = time.clock() | | 474 | + end_time = time.time() | 475 | 475 | print( | 476 | 476 | ( | 477 | 477 | 'Optimization complete with best validation score of %f %%, ' | |
Collapse file Copy file name to clipboardExpand all lines: code/cA.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -276,7 +276,7 @@ def test_cA(learning_rate=0.01, training_epochs=20, | 276 | 276 | } | 277 | 277 | ) | 278 | 278 |
| 279 | | - start_time = time.clock() | | 279 | + start_time = time.time() | 280 | 280 |
| 281 | 281 | ############ | 282 | 282 | # TRAINING # | @@ -293,7 +293,7 @@ def test_cA(learning_rate=0.01, training_epochs=20, | 293 | 293 | print 'Training epoch %d, reconstruction cost ' % epoch, numpy.mean( | 294 | 294 | c_array[0]), ' jacobian norm ', numpy.mean(numpy.sqrt(c_array[1])) | 295 | 295 |
| 296 | | - end_time = time.clock() | | 296 | + end_time = time.time() | 297 | 297 |
| 298 | 298 | training_time = (end_time - start_time) | 299 | 299 |
| |
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 |
|---|
@@ -274,7 +274,7 @@ def evaluate_lenet5(learning_rate=0.1, n_epochs=200, | 274 | 274 | best_validation_loss = numpy.inf | 275 | 275 | best_iter = 0 | 276 | 276 | test_score = 0. | 277 | | - start_time = time.clock() | | 277 | + start_time = time.time() | 278 | 278 |
| 279 | 279 | epoch = 0 | 280 | 280 | done_looping = False | @@ -326,7 +326,7 @@ def evaluate_lenet5(learning_rate=0.1, n_epochs=200, | 326 | 326 | done_looping = True | 327 | 327 | break | 328 | 328 |
| 329 | | - end_time = time.clock() | | 329 | + end_time = time.time() | 330 | 330 | print('Optimization complete.') | 331 | 331 | print('Best validation score of %f %% obtained at iteration %i, ' | 332 | 332 | 'with test performance %f %%' % | |
Collapse file Copy file name to clipboardExpand all lines: code/dA.py +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -321,7 +321,7 @@ def test_dA(learning_rate=0.1, training_epochs=15, | 321 | 321 | } | 322 | 322 | ) | 323 | 323 |
| 324 | | - start_time = time.clock() | | 324 | + start_time = time.time() | 325 | 325 |
| 326 | 326 | ############ | 327 | 327 | # TRAINING # | @@ -336,7 +336,7 @@ def test_dA(learning_rate=0.1, training_epochs=15, | 336 | 336 |
| 337 | 337 | print 'Training epoch %d, cost ' % epoch, numpy.mean(c) | 338 | 338 |
| 339 | | - end_time = time.clock() | | 339 | + end_time = time.time() | 340 | 340 |
| 341 | 341 | training_time = (end_time - start_time) | 342 | 342 |
| @@ -379,7 +379,7 @@ def test_dA(learning_rate=0.1, training_epochs=15, | 379 | 379 | } | 380 | 380 | ) | 381 | 381 |
| 382 | | - start_time = time.clock() | | 382 | + start_time = time.time() | 383 | 383 |
| 384 | 384 | ############ | 385 | 385 | # TRAINING # | @@ -394,7 +394,7 @@ def test_dA(learning_rate=0.1, training_epochs=15, | 394 | 394 |
| 395 | 395 | print 'Training epoch %d, cost ' % epoch, numpy.mean(c) | 396 | 396 |
| 397 | | - end_time = time.clock() | | 397 | + end_time = time.time() | 398 | 398 |
| 399 | 399 | training_time = (end_time - start_time) | 400 | 400 |
| |
Collapse file Copy file name to clipboardExpand all lines: code/logistic_cg.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -275,7 +275,7 @@ def callback(theta_value): | 275 | 275 | # using scipy conjugate gradient optimizer | 276 | 276 | import scipy.optimize | 277 | 277 | print ("Optimizing using scipy.optimize.fmin_cg...") | 278 | | - start_time = time.clock() | | 278 | + start_time = time.time() | 279 | 279 | best_w_b = scipy.optimize.fmin_cg( | 280 | 280 | f=train_fn, | 281 | 281 | x0=numpy.zeros((n_in + 1) * n_out, dtype=x.dtype), | @@ -284,7 +284,7 @@ def callback(theta_value): | 284 | 284 | disp=0, | 285 | 285 | maxiter=n_epochs | 286 | 286 | ) | 287 | | - end_time = time.clock() | | 287 | + end_time = time.time() | 288 | 288 | print( | 289 | 289 | ( | 290 | 290 | 'Optimization complete with best validation score of %f %%, with ' | |
Collapse file Copy file name to clipboardExpand all lines: code/logistic_sgd.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -360,7 +360,7 @@ def sgd_optimization_mnist(learning_rate=0.13, n_epochs=1000, | 360 | 360 |
| 361 | 361 | best_validation_loss = numpy.inf | 362 | 362 | test_score = 0. | 363 | | - start_time = time.clock() | | 363 | + start_time = time.time() | 364 | 364 |
| 365 | 365 | done_looping = False | 366 | 366 | epoch = 0 | @@ -419,7 +419,7 @@ def sgd_optimization_mnist(learning_rate=0.13, n_epochs=1000, | 419 | 419 | done_looping = True | 420 | 420 | break | 421 | 421 |
| 422 | | - end_time = time.clock() | | 422 | + end_time = time.time() | 423 | 423 | print( | 424 | 424 | ( | 425 | 425 | 'Optimization complete with best validation score of %f %%,' | |
Collapse file Copy file name to clipboardExpand all lines: code/lstm.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -543,7 +543,7 @@ def train_lstm( | 543 | 543 |
| 544 | 544 | uidx = 0 # the number of update done | 545 | 545 | estop = False # early stop | 546 | | - start_time = time.clock() | | 546 | + start_time = time.time() | 547 | 547 | try: | 548 | 548 | for eidx in xrange(max_epochs): | 549 | 549 | n_samples = 0 | @@ -622,7 +622,7 @@ def train_lstm( | 622 | 622 | except KeyboardInterrupt: | 623 | 623 | print "Training interupted" | 624 | 624 |
| 625 | | - end_time = time.clock() | | 625 | + end_time = time.time() | 626 | 626 | if best_p is not None: | 627 | 627 | zipp(best_p, tparams) | 628 | 628 | else: | |
Collapse file Copy file name to clipboardExpand all lines: code/mlp.py +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -336,7 +336,7 @@ def test_mlp(learning_rate=0.01, L1_reg=0.00, L2_reg=0.0001, n_epochs=1000, | 336 | 336 | best_validation_loss = numpy.inf | 337 | 337 | best_iter = 0 | 338 | 338 | test_score = 0. | 339 | | - start_time = time.clock() | | 339 | + start_time = time.time() | 340 | 340 |
| 341 | 341 | epoch = 0 | 342 | 342 | done_looping = False | @@ -391,7 +391,7 @@ def test_mlp(learning_rate=0.01, L1_reg=0.00, L2_reg=0.0001, n_epochs=1000, | 391 | 391 | done_looping = True | 392 | 392 | break | 393 | 393 |
| 394 | | - end_time = time.clock() | | 394 | + end_time = time.time() | 395 | 395 | print(('Optimization complete. Best validation score of %f %% ' | 396 | 396 | 'obtained at iteration %i, with test performance %f %%') % | 397 | 397 | (best_validation_loss * 100., best_iter + 1, test_score * 100.)) | |
Collapse file Copy file name to clipboardExpand all lines: code/rbm.py +4-4Lines changed: 4 additions & 4 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -428,7 +428,7 @@ def test_rbm(learning_rate=0.1, training_epochs=15, | 428 | 428 | ) | 429 | 429 |
| 430 | 430 | plotting_time = 0. | 431 | | - start_time = time.clock() | | 431 | + start_time = time.time() | 432 | 432 |
| 433 | 433 | # go through training epochs | 434 | 434 | for epoch in xrange(training_epochs): | @@ -441,7 +441,7 @@ def test_rbm(learning_rate=0.1, training_epochs=15, | 441 | 441 | print 'Training epoch %d, cost is ' % epoch, numpy.mean(mean_cost) | 442 | 442 |
| 443 | 443 | # Plot filters after each training epoch | 444 | | - plotting_start = time.clock() | | 444 | + plotting_start = time.time() | 445 | 445 | # Construct image from the weight matrix | 446 | 446 | image = Image.fromarray( | 447 | 447 | tile_raster_images( | @@ -452,10 +452,10 @@ def test_rbm(learning_rate=0.1, training_epochs=15, | 452 | 452 | ) | 453 | 453 | ) | 454 | 454 | image.save('filters_at_epoch_%i.png' % epoch) | 455 | | - plotting_stop = time.clock() | | 455 | + plotting_stop = time.time() | 456 | 456 | plotting_time += (plotting_stop - plotting_start) | 457 | 457 |
| 458 | | - end_time = time.clock() | | 458 | + end_time = time.time() | 459 | 459 |
| 460 | 460 | pretraining_time = (end_time - start_time) - plotting_time | 461 | 461 |
| |
|