Skip to content

Commit 362a8c0

Browse files
committed
indent.
1 parent da46247 commit 362a8c0

1 file changed

Lines changed: 39 additions & 38 deletions

File tree

code/mlp.py

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -302,44 +302,45 @@ def test_mlp(learning_rate=0.01, L1_reg=0.00, L2_reg=0.0001, n_epochs=1000,
302302
done_looping = False
303303

304304
while (epoch < n_epochs) and (not done_looping):
305-
epoch = epoch + 1
306-
for minibatch_index in xrange(n_train_batches):
307-
308-
minibatch_avg_cost = train_model(minibatch_index)
309-
# iteration number
310-
iter = epoch * n_train_batches + minibatch_index
311-
312-
if (iter + 1) % validation_frequency == 0:
313-
# compute zero-one loss on validation set
314-
validation_losses = [validate_model(i) for i
315-
in xrange(n_valid_batches)]
316-
this_validation_loss = numpy.mean(validation_losses)
317-
318-
print('epoch %i, minibatch %i/%i, validation error %f %%' %
319-
(epoch, minibatch_index + 1, n_train_batches,
320-
this_validation_loss * 100.))
321-
322-
# if we got the best validation score until now
323-
if this_validation_loss < best_validation_loss:
324-
#improve patience if loss improvement is good enough
325-
if this_validation_loss < best_validation_loss * \
326-
improvement_threshold:
327-
patience = max(patience, iter * patience_increase)
328-
329-
best_validation_loss = this_validation_loss
330-
# test it on the test set
331-
332-
test_losses = [test_model(i) for i in xrange(n_test_batches)]
333-
test_score = numpy.mean(test_losses)
334-
335-
print((' epoch %i, minibatch %i/%i, test error of best '
336-
'model %f %%') %
337-
(epoch, minibatch_index + 1, n_train_batches,
338-
test_score * 100.))
339-
340-
if patience <= iter:
341-
done_looping = True
342-
break
305+
epoch = epoch + 1
306+
for minibatch_index in xrange(n_train_batches):
307+
308+
minibatch_avg_cost = train_model(minibatch_index)
309+
# iteration number
310+
iter = epoch * n_train_batches + minibatch_index
311+
312+
if (iter + 1) % validation_frequency == 0:
313+
# compute zero-one loss on validation set
314+
validation_losses = [validate_model(i) for i
315+
in xrange(n_valid_batches)]
316+
this_validation_loss = numpy.mean(validation_losses)
317+
318+
print('epoch %i, minibatch %i/%i, validation error %f %%' %
319+
(epoch, minibatch_index + 1, n_train_batches,
320+
this_validation_loss * 100.))
321+
322+
# if we got the best validation score until now
323+
if this_validation_loss < best_validation_loss:
324+
#improve patience if loss improvement is good enough
325+
if this_validation_loss < best_validation_loss * \
326+
improvement_threshold:
327+
patience = max(patience, iter * patience_increase)
328+
329+
best_validation_loss = this_validation_loss
330+
# test it on the test set
331+
332+
test_losses = [test_model(i) for i
333+
in xrange(n_test_batches)]
334+
test_score = numpy.mean(test_losses)
335+
336+
print((' epoch %i, minibatch %i/%i, test error of '
337+
'best model %f %%') %
338+
(epoch, minibatch_index + 1, n_train_batches,
339+
test_score * 100.))
340+
341+
if patience <= iter:
342+
done_looping = True
343+
break
343344

344345
end_time = time.clock()
345346
print(('Optimization complete. Best validation score of %f %% '

0 commit comments

Comments
 (0)