From: Martin Pitt Date: Sun, 30 Aug 2020 08:19:10 +0000 (+0200) Subject: Use linearly falling learning rate X-Git-Url: https://piware.de/gitweb/?a=commitdiff_plain;h=59f4fd752941f39ddcd36760202a0dc742747106;p=handwriting-recognition.git Use linearly falling learning rate This makes big strides on the completely untrained network, but treads more carefully later on. Prevents overshooting with reLU, and even slightly improves Sigmoid. --- diff --git a/train.py b/train.py index 8510624..b294ce1 100755 --- a/train.py +++ b/train.py @@ -28,7 +28,7 @@ print(f'correctly recognized images after initialization: {nnet.accuracy(net, te train_y = nnet.label_vectors(train_labels, 10) for i in range(100): for batch in range(0, num_train, nnet_batch): - cost = nnet.train(net, train_images[:, batch:(batch + nnet_batch)], train_y[:, batch:(batch + nnet_batch)], learning_rate=1) + cost = nnet.train(net, train_images[:, batch:(batch + nnet_batch)], train_y[:, batch:(batch + nnet_batch)], learning_rate=(100-i)/100) print(f'cost after training round {i}: {cost}') print(f'correctly recognized images after training: {nnet.accuracy(net, test_images, test_labels)}%')