"This tutorial focuses on implementation of three reqularisaion techniques, two of them are norm based approaches which are added to optimised objective and the third technique, called *droput*, is a form of noise injection by random corruption of information carried by hidden units during training.\n",
"\n",
"\n",
"## Virtual environments\n",
"\n",
"Before you proceed onwards, remember to activate your virtual environment:\n",
" * If you were in last week's Tuesday or Wednesday group type `activate_mlp` or `source ~/mlpractical/venv/bin/activate`\n",
" * If you were in the Monday group:\n",
" + and if you have chosen the **comfy** way type: `workon mlpractical`\n",
" + and if you have chosen the **generic** way, `source` your virutal environment using `source` and specyfing the path to the activate script (you need to localise it yourself, there were not any general recommendations w.r.t dir structure and people have installed it in different places, usually somewhere in the home directories. If you cannot easily find it by yourself, use something like: `find . -iname activate` ):\n",
"\n",
"## Syncing the git repository\n",
"\n",
"Look <a href=\"https://github.com/CSTR-Edinburgh/mlpractical/blob/master/gitFAQ.md\">here</a> for more details. But in short, we recommend to create a separate branch for this lab, as follows:\n",
"\n",
"1. Enter the mlpractical directory `cd ~/mlpractical/repo-mlp`\n",
"2. List the branches and check which is currently active by typing: `git branch`\n",
"3. If you have followed our recommendations, you should be in the `coursework1` branch, please commit your local changed to the repo index by typing:\n",
"```\n",
"git commit -am \"finished coursework\"\n",
"```\n",
"4. Now you can switch to `master` branch by typing: \n",
"```\n",
"git checkout master\n",
" ```\n",
"5. To update the repository (note, assuming master does not have any conflicts), if there are some, have a look <a href=\"https://github.com/CSTR-Edinburgh/mlpractical/blob/master/gitFAQ.md\">here</a>\n",
"```\n",
"git pull\n",
"```\n",
"6. And now, create the new branch & swith to it by typing:\n",
"```\n",
"git checkout -b lab4\n",
"```"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Regularisation\n",
"\n",
"Regularisation add some *complexity term* to the cost function. It's purpose is to put some prior on the model's parameters. The most common prior is perhaps the one which assumes smoother solutions (the one which are not able to fit training data too well) are better as they are more likely to better generalise to unseen data. \n",
"\n",
"A way to incorporate such prior in the model is to add some term that penalise certain configurations of the parameters -- either from growing too large ($L_2$) or the one that prefers solution that could be modelled with less parameters ($L_1$), hence encouraging some parameters to become 0. One can, of course, combine many such priors when optimising the model, however, in the lab we shall use $L_1$ and/or $L_2$ priors.\n",
"\n",
"They can be easily incorporated into the training objective by adding some additive terms, as follows:\n",
"where $ E^n_{\\text{train}} = - \\sum_{k=1}^K t^n_k \\ln y^n_k $, $\\beta_{L_1}$ and $\\beta_{L_2}$ some non-negative constants specified a priori (hyper-parameters) and $E^n_{L_1}$ and $E^n_{L_2}$ norm metric specifying certain properties of parameters:\n",
"Where $\\mbox{sgn}(w_i)$ is the sign of $w_i$: $\\mbox{sgn}(w_i) = 1$ if $w_i>0$ and $\\mbox{sgn}(w_i) = -1$ if $w_i<0$\n",
"\n",
"One can also apply those penalty terms for biases, however, this is usually not necessary as biases have secondary impact on smoothnes of the given solution.\n",
"\n",
"## Dropout\n",
"\n",
"Dropout, for a given layer's output $\\mathbf{h}^i \\in \\mathbb{R}^{BxH^l}$ (where $B$ is batch size and $H^l$ is the $l$-th layer output dimensionality) implements the following transformation:\n",
"where $\\circ$ denotes an elementwise product and $\\mathbf{d}^l \\in \\{0,1\\}^{BxH^i}$ is a matrix in which $d^l_{ij}$ element is sampled from the Bernoulli distribution:\n",
"with $0<p^l_d<1$ denoting the probability the given unit is kept unchanged (dropping probability is thus $1-p^l_d$). We ignore here edge scenarios where $p^l_d=1$ and there is no dropout applied (and the training would be exactly the same as in standard SGD) and $p^l_d=0$ where all units would have been dropped, hence the model would not learn anything.\n",
"\n",
"The probability $p^l_d$ is a hyperparameter (like learning rate) meaning it needs to be provided before training and also very often tuned for the given task. As the notation suggest, it can be specified separately for each layer, including scenario where $l=0$ when some random input features (pixels in the image for MNIST) are being also ommitted.\n",
"\n",
"### Keeping the $l$-th layer output $\\mathbf{\\hat h}^l$ (input to the upper layer) appropiately scaled at test-time\n",
"\n",
"The other issue one needs to take into account is the mismatch that arises between training and test (runtime) stages when dropout is applied. It is due to the fact that droput is not applied when testing hence the average input to the unit in upper layer is going to be bigger when compared to training stage (where some inputs are set to 0), in average $1/p^l_d$ times bigger. \n",
"\n",
"So to account for this mismatch one could either:\n",
"\n",
"1. When training is finished scale the final weight matrices $\\mathbf{W}^l, l=1,\\ldots,L$ by $p^{l-1}_d$ (remember, $p^{0}_d$ is the probability related to the input features)\n",
"2. Scale the activations in equation (9) during training, that is, for each mini-batch multiply $\\mathbf{\\hat h}^l$ by $1/p^l_d$ to compensate for dropped units and then at run-time use the model as usual, **without** scaling. Make sure the $1/p^l_d$ scaler is taken into account for both forward and backward passes.\n",
"\n",
"\n",
"Our recommendation is option 2 as it will make some things easier from implementation perspective. "
"# Exercise 1: Implement L1 based regularisation\n",
"\n",
"Implement L1 regularisation penalty (just for weight matrices, ignore biases). Test your solution on one hidden layer model similar to the one from coursework's Task 4 (800 hidden units) but limit training data to 10 000 (random) data-points (keep validation and test sets the same). First build and train not-regularised model as a basline. Then train regularised model starting with $\\beta_{L1}$ set to 0.001 and do some grid search for better values. Plot validation accuracies as a function of epochs for each model (each $\\beta_{L1}$ you tried).\n",
"\n",
"Implementation tips:\n",
"* Have a look at the constructor of mlp.optimiser.SGDOptimiser class, it has been modified to take more optimisation-related arguments.\n",
"* The best place to implement regularisation terms is `pgrads` method of mlp.layers.Layer (sub)-classes (look at equations (5) and (8) to see why). Some modifications are also required in `train_epoch`."
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:root:Training started...\n",
"INFO:mlp.optimisers:Epoch 0: Training cost (ce) for initial model is 8.934. Accuracy is 8.60%\n",
"INFO:mlp.optimisers:Epoch 0: Validation cost (ce) for initial model is 8.863. Accuracy is 9.84%\n",
"INFO:mlp.optimisers:Epoch 1: Training cost (ce) is 9.299. Accuracy is 58.20%\n",
"INFO:mlp.optimisers:Epoch 1: Validation cost (ce) is 6.952. Accuracy is 81.23%\n",
"INFO:mlp.optimisers:Epoch 1: Took 12 seconds. Training speed 261 pps. Validation speed 1285 pps.\n",
"INFO:mlp.optimisers:Epoch 2: Training cost (ce) is 6.838. Accuracy is 84.10%\n",
"INFO:mlp.optimisers:Epoch 2: Validation cost (ce) is 6.776. Accuracy is 86.86%\n",
"INFO:mlp.optimisers:Epoch 2: Took 10 seconds. Training speed 248 pps. Validation speed 1546 pps.\n",
"INFO:mlp.optimisers:Epoch 3: Training cost (ce) is 6.661. Accuracy is 89.60%\n",
"INFO:mlp.optimisers:Epoch 3: Validation cost (ce) is 6.741. Accuracy is 87.56%\n",
"INFO:mlp.optimisers:Epoch 3: Took 11 seconds. Training speed 257 pps. Validation speed 1499 pps.\n",
"INFO:mlp.optimisers:Epoch 4: Training cost (ce) is 6.541. Accuracy is 92.60%\n",
"INFO:mlp.optimisers:Epoch 4: Validation cost (ce) is 6.729. Accuracy is 87.59%\n",
"INFO:mlp.optimisers:Epoch 4: Took 10 seconds. Training speed 268 pps. Validation speed 1495 pps.\n",
"INFO:mlp.optimisers:Epoch 5: Training cost (ce) is 6.458. Accuracy is 95.30%\n",
"INFO:mlp.optimisers:Epoch 5: Validation cost (ce) is 6.853. Accuracy is 82.51%\n",
"INFO:mlp.optimisers:Epoch 5: Took 12 seconds. Training speed 267 pps. Validation speed 1220 pps.\n",
"INFO:mlp.optimisers:Epoch 6: Training cost (ce) is 6.400. Accuracy is 96.80%\n",
"INFO:mlp.optimisers:Epoch 6: Validation cost (ce) is 6.636. Accuracy is 89.53%\n",
"INFO:mlp.optimisers:Epoch 6: Took 12 seconds. Training speed 258 pps. Validation speed 1235 pps.\n",
"INFO:mlp.optimisers:Epoch 7: Training cost (ce) is 6.333. Accuracy is 98.40%\n",
"INFO:mlp.optimisers:Epoch 7: Validation cost (ce) is 6.622. Accuracy is 89.54%\n",
"INFO:mlp.optimisers:Epoch 7: Took 12 seconds. Training speed 253 pps. Validation speed 1214 pps.\n",
"INFO:mlp.optimisers:Epoch 8: Training cost (ce) is 6.290. Accuracy is 98.70%\n",
"INFO:mlp.optimisers:Epoch 8: Validation cost (ce) is 6.616. Accuracy is 89.02%\n",
"INFO:mlp.optimisers:Epoch 8: Took 14 seconds. Training speed 253 pps. Validation speed 1023 pps.\n",
"INFO:mlp.optimisers:Epoch 9: Training cost (ce) is 6.246. Accuracy is 99.20%\n",
"INFO:mlp.optimisers:Epoch 9: Validation cost (ce) is 6.576. Accuracy is 89.49%\n",
"INFO:mlp.optimisers:Epoch 9: Took 12 seconds. Training speed 259 pps. Validation speed 1299 pps.\n",
"INFO:mlp.optimisers:Epoch 10: Training cost (ce) is 6.206. Accuracy is 99.40%\n",
"INFO:mlp.optimisers:Epoch 10: Validation cost (ce) is 6.554. Accuracy is 89.61%\n",
"INFO:mlp.optimisers:Epoch 10: Took 11 seconds. Training speed 270 pps. Validation speed 1307 pps.\n",
"INFO:mlp.optimisers:Epoch 11: Training cost (ce) is 6.172. Accuracy is 99.50%\n",
"INFO:mlp.optimisers:Epoch 11: Validation cost (ce) is 6.533. Accuracy is 89.83%\n",
"INFO:mlp.optimisers:Epoch 11: Took 12 seconds. Training speed 252 pps. Validation speed 1205 pps.\n",
"INFO:mlp.optimisers:Epoch 12: Training cost (ce) is 6.136. Accuracy is 99.40%\n",
"INFO:mlp.optimisers:Epoch 12: Validation cost (ce) is 6.517. Accuracy is 89.65%\n",
"INFO:mlp.optimisers:Epoch 12: Took 12 seconds. Training speed 255 pps. Validation speed 1292 pps.\n",
"INFO:mlp.optimisers:Epoch 13: Training cost (ce) is 6.105. Accuracy is 99.60%\n",
"INFO:mlp.optimisers:Epoch 13: Validation cost (ce) is 6.484. Accuracy is 89.90%\n",
"INFO:mlp.optimisers:Epoch 13: Took 12 seconds. Training speed 257 pps. Validation speed 1290 pps.\n",
"INFO:mlp.optimisers:Epoch 14: Training cost (ce) is 6.074. Accuracy is 99.80%\n",
"INFO:mlp.optimisers:Epoch 14: Validation cost (ce) is 6.457. Accuracy is 89.87%\n",
"INFO:mlp.optimisers:Epoch 14: Took 11 seconds. Training speed 260 pps. Validation speed 1337 pps.\n",
"INFO:mlp.optimisers:Epoch 15: Training cost (ce) is 6.041. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 15: Validation cost (ce) is 6.439. Accuracy is 89.76%\n",
"INFO:mlp.optimisers:Epoch 15: Took 11 seconds. Training speed 263 pps. Validation speed 1311 pps.\n",
"INFO:mlp.optimisers:Epoch 16: Training cost (ce) is 6.011. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 16: Validation cost (ce) is 6.411. Accuracy is 89.89%\n",
"INFO:mlp.optimisers:Epoch 16: Took 12 seconds. Training speed 261 pps. Validation speed 1263 pps.\n",
"INFO:mlp.optimisers:Epoch 17: Training cost (ce) is 5.981. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 17: Validation cost (ce) is 6.385. Accuracy is 89.94%\n",
"INFO:mlp.optimisers:Epoch 17: Took 12 seconds. Training speed 258 pps. Validation speed 1276 pps.\n",
"INFO:mlp.optimisers:Epoch 18: Training cost (ce) is 5.952. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 18: Validation cost (ce) is 6.360. Accuracy is 89.98%\n",
"INFO:mlp.optimisers:Epoch 18: Took 12 seconds. Training speed 255 pps. Validation speed 1306 pps.\n",
"INFO:mlp.optimisers:Epoch 19: Training cost (ce) is 5.922. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 19: Validation cost (ce) is 6.335. Accuracy is 89.86%\n",
"INFO:mlp.optimisers:Epoch 19: Took 10 seconds. Training speed 259 pps. Validation speed 1536 pps.\n",
"INFO:mlp.optimisers:Epoch 20: Training cost (ce) is 5.893. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 20: Validation cost (ce) is 6.312. Accuracy is 89.92%\n",
"INFO:mlp.optimisers:Epoch 20: Took 12 seconds. Training speed 255 pps. Validation speed 1255 pps.\n",
"INFO:mlp.optimisers:Epoch 21: Training cost (ce) is 5.864. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 21: Validation cost (ce) is 6.283. Accuracy is 89.84%\n",
"INFO:mlp.optimisers:Epoch 21: Took 10 seconds. Training speed 279 pps. Validation speed 1543 pps.\n",
"INFO:mlp.optimisers:Epoch 22: Training cost (ce) is 5.835. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 22: Validation cost (ce) is 6.258. Accuracy is 89.92%\n",
"INFO:mlp.optimisers:Epoch 22: Took 11 seconds. Training speed 254 pps. Validation speed 1335 pps.\n",
"INFO:mlp.optimisers:Epoch 23: Training cost (ce) is 5.806. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 23: Validation cost (ce) is 6.232. Accuracy is 89.97%\n",
"INFO:mlp.optimisers:Epoch 23: Took 11 seconds. Training speed 256 pps. Validation speed 1378 pps.\n",
"INFO:mlp.optimisers:Epoch 24: Training cost (ce) is 5.777. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 24: Validation cost (ce) is 6.202. Accuracy is 90.04%\n",
"INFO:mlp.optimisers:Epoch 24: Took 13 seconds. Training speed 255 pps. Validation speed 1133 pps.\n",
"INFO:mlp.optimisers:Epoch 25: Training cost (ce) is 5.748. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 25: Validation cost (ce) is 6.178. Accuracy is 89.96%\n",
"INFO:mlp.optimisers:Epoch 25: Took 12 seconds. Training speed 253 pps. Validation speed 1233 pps.\n",
"INFO:mlp.optimisers:Epoch 26: Training cost (ce) is 5.720. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 26: Validation cost (ce) is 6.157. Accuracy is 89.90%\n",
"INFO:mlp.optimisers:Epoch 26: Took 12 seconds. Training speed 259 pps. Validation speed 1260 pps.\n",
"INFO:mlp.optimisers:Epoch 27: Training cost (ce) is 5.691. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 27: Validation cost (ce) is 6.125. Accuracy is 89.90%\n",
"INFO:mlp.optimisers:Epoch 27: Took 11 seconds. Training speed 283 pps. Validation speed 1357 pps.\n",
"INFO:mlp.optimisers:Epoch 28: Training cost (ce) is 5.662. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 28: Validation cost (ce) is 6.099. Accuracy is 89.90%\n",
"INFO:mlp.optimisers:Epoch 28: Took 12 seconds. Training speed 257 pps. Validation speed 1247 pps.\n",
"INFO:mlp.optimisers:Epoch 29: Training cost (ce) is 5.634. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 29: Validation cost (ce) is 6.067. Accuracy is 90.03%\n",
"INFO:mlp.optimisers:Epoch 29: Took 12 seconds. Training speed 257 pps. Validation speed 1256 pps.\n",
"INFO:mlp.optimisers:Epoch 30: Training cost (ce) is 5.605. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 30: Validation cost (ce) is 6.043. Accuracy is 89.94%\n",
"INFO:mlp.optimisers:Epoch 30: Took 12 seconds. Training speed 256 pps. Validation speed 1285 pps.\n",
"INFO:root:Testing the model on test set:\n",
"INFO:root:MNIST test set accuracy is 89.30 %, cost (ce) is 0.448\n"
"# Exercise 2: Implement L2 based regularisation\n",
"\n",
"Implement L2 regularisation method. Follow similar steps as in Exercise 1. Start with $\\beta_{L2}$ set to 0.001 and do some grid search for better values. Plot validation accuracies as a function of epochs for each model."
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:root:Training started...\n",
"INFO:mlp.optimisers:Epoch 0: Training cost (ce) for initial model is 2.666. Accuracy is 8.60%\n",
"INFO:mlp.optimisers:Epoch 0: Validation cost (ce) for initial model is 2.595. Accuracy is 9.84%\n",
"INFO:mlp.optimisers:Epoch 1: Training cost (ce) is 2.862. Accuracy is 58.70%\n",
"INFO:mlp.optimisers:Epoch 1: Validation cost (ce) is 0.772. Accuracy is 75.41%\n",
"INFO:mlp.optimisers:Epoch 1: Took 12 seconds. Training speed 255 pps. Validation speed 1302 pps.\n",
"INFO:mlp.optimisers:Epoch 2: Training cost (ce) is 0.544. Accuracy is 83.30%\n",
"INFO:mlp.optimisers:Epoch 2: Validation cost (ce) is 0.547. Accuracy is 83.96%\n",
"INFO:mlp.optimisers:Epoch 2: Took 11 seconds. Training speed 252 pps. Validation speed 1397 pps.\n",
"INFO:mlp.optimisers:Epoch 3: Training cost (ce) is 0.361. Accuracy is 90.60%\n",
"INFO:mlp.optimisers:Epoch 3: Validation cost (ce) is 0.538. Accuracy is 84.64%\n",
"INFO:mlp.optimisers:Epoch 3: Took 9 seconds. Training speed 328 pps. Validation speed 1565 pps.\n",
"INFO:mlp.optimisers:Epoch 4: Training cost (ce) is 0.270. Accuracy is 92.70%\n",
"INFO:mlp.optimisers:Epoch 4: Validation cost (ce) is 0.442. Accuracy is 88.85%\n",
"INFO:mlp.optimisers:Epoch 4: Took 12 seconds. Training speed 250 pps. Validation speed 1299 pps.\n",
"INFO:mlp.optimisers:Epoch 5: Training cost (ce) is 0.218. Accuracy is 94.60%\n",
"INFO:mlp.optimisers:Epoch 5: Validation cost (ce) is 0.444. Accuracy is 88.78%\n",
"INFO:mlp.optimisers:Epoch 5: Took 10 seconds. Training speed 294 pps. Validation speed 1543 pps.\n",
"INFO:mlp.optimisers:Epoch 6: Training cost (ce) is 0.179. Accuracy is 96.60%\n",
"INFO:mlp.optimisers:Epoch 6: Validation cost (ce) is 0.462. Accuracy is 88.42%\n",
"INFO:mlp.optimisers:Epoch 6: Took 10 seconds. Training speed 307 pps. Validation speed 1543 pps.\n",
"INFO:mlp.optimisers:Epoch 7: Training cost (ce) is 0.135. Accuracy is 98.40%\n",
"INFO:mlp.optimisers:Epoch 7: Validation cost (ce) is 0.418. Accuracy is 89.87%\n",
"INFO:mlp.optimisers:Epoch 7: Took 10 seconds. Training speed 297 pps. Validation speed 1548 pps.\n",
"INFO:mlp.optimisers:Epoch 8: Training cost (ce) is 0.109. Accuracy is 99.30%\n",
"INFO:mlp.optimisers:Epoch 8: Validation cost (ce) is 0.434. Accuracy is 89.65%\n",
"INFO:mlp.optimisers:Epoch 8: Took 12 seconds. Training speed 292 pps. Validation speed 1217 pps.\n",
"INFO:mlp.optimisers:Epoch 9: Training cost (ce) is 0.089. Accuracy is 99.30%\n",
"INFO:mlp.optimisers:Epoch 9: Validation cost (ce) is 0.451. Accuracy is 89.26%\n",
"INFO:mlp.optimisers:Epoch 9: Took 11 seconds. Training speed 311 pps. Validation speed 1348 pps.\n",
"INFO:mlp.optimisers:Epoch 10: Training cost (ce) is 0.088. Accuracy is 99.50%\n",
"INFO:mlp.optimisers:Epoch 10: Validation cost (ce) is 0.459. Accuracy is 89.22%\n",
"INFO:mlp.optimisers:Epoch 10: Took 9 seconds. Training speed 325 pps. Validation speed 1600 pps.\n",
"INFO:mlp.optimisers:Epoch 11: Training cost (ce) is 0.074. Accuracy is 99.80%\n",
"INFO:mlp.optimisers:Epoch 11: Validation cost (ce) is 0.443. Accuracy is 90.03%\n",
"INFO:mlp.optimisers:Epoch 11: Took 11 seconds. Training speed 274 pps. Validation speed 1325 pps.\n",
"INFO:mlp.optimisers:Epoch 12: Training cost (ce) is 0.070. Accuracy is 99.80%\n",
"INFO:mlp.optimisers:Epoch 12: Validation cost (ce) is 0.452. Accuracy is 90.10%\n",
"INFO:mlp.optimisers:Epoch 12: Took 12 seconds. Training speed 288 pps. Validation speed 1133 pps.\n",
"INFO:mlp.optimisers:Epoch 13: Training cost (ce) is 0.064. Accuracy is 99.70%\n",
"INFO:mlp.optimisers:Epoch 13: Validation cost (ce) is 0.485. Accuracy is 89.01%\n",
"INFO:mlp.optimisers:Epoch 13: Took 11 seconds. Training speed 315 pps. Validation speed 1218 pps.\n",
"INFO:mlp.optimisers:Epoch 14: Training cost (ce) is 0.060. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 14: Validation cost (ce) is 0.457. Accuracy is 90.14%\n",
"INFO:mlp.optimisers:Epoch 14: Took 12 seconds. Training speed 282 pps. Validation speed 1245 pps.\n",
"INFO:mlp.optimisers:Epoch 15: Training cost (ce) is 0.059. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 15: Validation cost (ce) is 0.459. Accuracy is 90.29%\n",
"INFO:mlp.optimisers:Epoch 15: Took 11 seconds. Training speed 280 pps. Validation speed 1268 pps.\n",
"INFO:mlp.optimisers:Epoch 16: Training cost (ce) is 0.057. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 16: Validation cost (ce) is 0.465. Accuracy is 90.00%\n",
"INFO:mlp.optimisers:Epoch 16: Took 10 seconds. Training speed 328 pps. Validation speed 1368 pps.\n",
"INFO:mlp.optimisers:Epoch 17: Training cost (ce) is 0.056. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 17: Validation cost (ce) is 0.467. Accuracy is 90.14%\n",
"INFO:mlp.optimisers:Epoch 17: Took 11 seconds. Training speed 273 pps. Validation speed 1287 pps.\n",
"INFO:mlp.optimisers:Epoch 18: Training cost (ce) is 0.055. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 18: Validation cost (ce) is 0.475. Accuracy is 90.15%\n",
"INFO:mlp.optimisers:Epoch 18: Took 11 seconds. Training speed 279 pps. Validation speed 1279 pps.\n",
"INFO:mlp.optimisers:Epoch 19: Training cost (ce) is 0.054. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 19: Validation cost (ce) is 0.473. Accuracy is 90.06%\n",
"INFO:mlp.optimisers:Epoch 19: Took 12 seconds. Training speed 284 pps. Validation speed 1188 pps.\n",
"INFO:mlp.optimisers:Epoch 20: Training cost (ce) is 0.053. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 20: Validation cost (ce) is 0.478. Accuracy is 90.06%\n",
"INFO:mlp.optimisers:Epoch 20: Took 13 seconds. Training speed 250 pps. Validation speed 1172 pps.\n",
"INFO:mlp.optimisers:Epoch 21: Training cost (ce) is 0.053. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 21: Validation cost (ce) is 0.484. Accuracy is 90.05%\n",
"INFO:mlp.optimisers:Epoch 21: Took 11 seconds. Training speed 255 pps. Validation speed 1325 pps.\n",
"INFO:mlp.optimisers:Epoch 22: Training cost (ce) is 0.052. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 22: Validation cost (ce) is 0.485. Accuracy is 90.21%\n",
"INFO:mlp.optimisers:Epoch 22: Took 10 seconds. Training speed 328 pps. Validation speed 1353 pps.\n",
"INFO:mlp.optimisers:Epoch 23: Training cost (ce) is 0.052. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 23: Validation cost (ce) is 0.484. Accuracy is 90.08%\n",
"INFO:mlp.optimisers:Epoch 23: Took 11 seconds. Training speed 266 pps. Validation speed 1332 pps.\n",
"INFO:mlp.optimisers:Epoch 24: Training cost (ce) is 0.051. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 24: Validation cost (ce) is 0.485. Accuracy is 90.17%\n",
"INFO:mlp.optimisers:Epoch 24: Took 10 seconds. Training speed 281 pps. Validation speed 1520 pps.\n",
"INFO:mlp.optimisers:Epoch 25: Training cost (ce) is 0.051. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 25: Validation cost (ce) is 0.486. Accuracy is 90.26%\n",
"INFO:mlp.optimisers:Epoch 25: Took 11 seconds. Training speed 259 pps. Validation speed 1321 pps.\n",
"INFO:mlp.optimisers:Epoch 26: Training cost (ce) is 0.051. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 26: Validation cost (ce) is 0.487. Accuracy is 90.23%\n",
"INFO:mlp.optimisers:Epoch 26: Took 11 seconds. Training speed 283 pps. Validation speed 1344 pps.\n",
"INFO:mlp.optimisers:Epoch 27: Training cost (ce) is 0.051. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 27: Validation cost (ce) is 0.493. Accuracy is 90.25%\n",
"INFO:mlp.optimisers:Epoch 27: Took 11 seconds. Training speed 270 pps. Validation speed 1357 pps.\n",
"INFO:mlp.optimisers:Epoch 28: Training cost (ce) is 0.050. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 28: Validation cost (ce) is 0.493. Accuracy is 90.27%\n",
"INFO:mlp.optimisers:Epoch 28: Took 11 seconds. Training speed 283 pps. Validation speed 1302 pps.\n",
"INFO:mlp.optimisers:Epoch 29: Training cost (ce) is 0.050. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 29: Validation cost (ce) is 0.499. Accuracy is 90.22%\n",
"INFO:mlp.optimisers:Epoch 29: Took 10 seconds. Training speed 327 pps. Validation speed 1395 pps.\n",
"INFO:mlp.optimisers:Epoch 30: Training cost (ce) is 0.050. Accuracy is 100.00%\n",
"INFO:mlp.optimisers:Epoch 30: Validation cost (ce) is 0.497. Accuracy is 90.22%\n",
"INFO:mlp.optimisers:Epoch 30: Took 12 seconds. Training speed 268 pps. Validation speed 1142 pps.\n",
"INFO:root:Testing the model on test set:\n",
"INFO:root:MNIST test set accuracy is 89.30 %, cost (ce) is 0.459\n"
"Droput applied to input features (turning on/off some random pixels) may be also viewed as a form of data augmentation -- as we effectively create images that differ in some way from training one but also model is tasked to properly classify imperfect data-points.\n",
"\n",
"Your task in this exercise is to pick a random digit from MNIST dataset (use MNISTDataProvider) and corrupt it pixel-wise with different levels of probabilities $p_{d} \\in \\{0.9, 0.7, 0.5, 0.2, 0.1\\}$ (reminder, dropout probability is $1-p_d$) that is, for each pixel $x_{i,j}$ in image $\\mathbf{X} \\in \\mathbb{R}^{W\\times H}$:\n",
"Implement dropout regularisation technique. Then for the same initial configuration as in Exercise 1. investigate effectivness of different dropout rates applied to input features and/or hidden layers. Start with $p_{inp}=0.5$ and $p_{hid}=0.5$ and do some search for better settings.\n",
"\n",
"Implementation tips:\n",
"* Add a function `fprop_dropout` to `mlp.layers.MLP` class which (on top of `inputs` argument) takes also dropout-related argument(s) and perform dropout forward propagation through the model.\n",
"* One also would have to introduce required modificastions to `mlp.optimisers.SGDOptimiser.train_epoch()` function.\n",
"* Design and implemnt dropout scheduler in a similar way to how learning rates are handled (that is, allowing for some implementation dependent schedule which is kept independent of implementation in `mlp.optimisers.SGDOptimiser.train()`). \n",
" + For this exercise implement only fixed dropout scheduler - `DropoutFixed`, but implementation should allow to easily add other schedules in the future. \n",
" + Dropout scheduler of any type should return a tuple of two numbers $(p_{inp},\\; p_{hid})$, the first one is dropout factor for input features (data-points), and the latter dropout factor for hidden layers (assumed the same for all hidden layers)."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"INFO:root:Training started...\n",
"INFO:mlp.optimisers:Epoch 0: Training cost (ce) for initial model is 2.624. Accuracy is 8.60%\n",
"INFO:mlp.optimisers:Epoch 0: Validation cost (ce) for initial model is 2.554. Accuracy is 9.84%\n",
"INFO:mlp.optimisers:Epoch 1: Training cost (ce) is 3.828. Accuracy is 50.90%\n",
"INFO:mlp.optimisers:Epoch 1: Validation cost (ce) is 0.716. Accuracy is 76.93%\n",
"INFO:mlp.optimisers:Epoch 1: Took 9 seconds. Training speed 295 pps. Validation speed 1692 pps.\n",
"INFO:mlp.optimisers:Epoch 2: Training cost (ce) is 1.132. Accuracy is 66.90%\n",
"INFO:mlp.optimisers:Epoch 2: Validation cost (ce) is 0.753. Accuracy is 78.82%\n",
"INFO:mlp.optimisers:Epoch 2: Took 10 seconds. Training speed 289 pps. Validation speed 1653 pps.\n",
"INFO:mlp.optimisers:Epoch 3: Training cost (ce) is 1.043. Accuracy is 71.90%\n",
"INFO:mlp.optimisers:Epoch 3: Validation cost (ce) is 0.501. Accuracy is 85.69%\n",
"INFO:mlp.optimisers:Epoch 3: Took 10 seconds. Training speed 280 pps. Validation speed 1681 pps.\n",
"INFO:mlp.optimisers:Epoch 4: Training cost (ce) is 0.810. Accuracy is 78.50%\n",
"INFO:mlp.optimisers:Epoch 4: Validation cost (ce) is 0.481. Accuracy is 85.92%\n",
"INFO:mlp.optimisers:Epoch 4: Took 9 seconds. Training speed 308 pps. Validation speed 1675 pps.\n",
"INFO:mlp.optimisers:Epoch 5: Training cost (ce) is 0.769. Accuracy is 79.40%\n",
"INFO:mlp.optimisers:Epoch 5: Validation cost (ce) is 0.588. Accuracy is 84.25%\n",
"INFO:mlp.optimisers:Epoch 5: Took 9 seconds. Training speed 320 pps. Validation speed 1733 pps.\n",
"INFO:mlp.optimisers:Epoch 6: Training cost (ce) is 0.792. Accuracy is 78.60%\n",
"INFO:mlp.optimisers:Epoch 6: Validation cost (ce) is 0.434. Accuracy is 88.49%\n",
"INFO:mlp.optimisers:Epoch 6: Took 9 seconds. Training speed 334 pps. Validation speed 1692 pps.\n",
"INFO:mlp.optimisers:Epoch 7: Training cost (ce) is 0.675. Accuracy is 82.00%\n",
"INFO:mlp.optimisers:Epoch 7: Validation cost (ce) is 0.514. Accuracy is 86.76%\n",
"INFO:mlp.optimisers:Epoch 7: Took 9 seconds. Training speed 284 pps. Validation speed 1704 pps.\n",
"INFO:mlp.optimisers:Epoch 8: Training cost (ce) is 0.808. Accuracy is 79.90%\n",
"INFO:mlp.optimisers:Epoch 8: Validation cost (ce) is 0.620. Accuracy is 84.22%\n",
"INFO:mlp.optimisers:Epoch 8: Took 9 seconds. Training speed 317 pps. Validation speed 1684 pps.\n",
"INFO:mlp.optimisers:Epoch 9: Training cost (ce) is 0.810. Accuracy is 79.90%\n",
"INFO:mlp.optimisers:Epoch 9: Validation cost (ce) is 0.645. Accuracy is 84.91%\n",
"INFO:mlp.optimisers:Epoch 9: Took 9 seconds. Training speed 304 pps. Validation speed 1675 pps.\n",
"INFO:mlp.optimisers:Epoch 10: Training cost (ce) is 0.631. Accuracy is 83.20%\n",
"INFO:mlp.optimisers:Epoch 10: Validation cost (ce) is 0.493. Accuracy is 88.80%\n",
"INFO:mlp.optimisers:Epoch 10: Took 10 seconds. Training speed 286 pps. Validation speed 1656 pps.\n",
"INFO:mlp.optimisers:Epoch 11: Training cost (ce) is 0.676. Accuracy is 83.90%\n",
"INFO:mlp.optimisers:Epoch 11: Validation cost (ce) is 0.598. Accuracy is 86.78%\n",
"INFO:mlp.optimisers:Epoch 11: Took 9 seconds. Training speed 296 pps. Validation speed 1710 pps.\n",
"INFO:mlp.optimisers:Epoch 12: Training cost (ce) is 0.659. Accuracy is 83.80%\n",
"INFO:mlp.optimisers:Epoch 12: Validation cost (ce) is 0.432. Accuracy is 90.21%\n",
"INFO:mlp.optimisers:Epoch 12: Took 9 seconds. Training speed 309 pps. Validation speed 1675 pps.\n",
"INFO:mlp.optimisers:Epoch 13: Training cost (ce) is 0.525. Accuracy is 86.80%\n",
"INFO:mlp.optimisers:Epoch 13: Validation cost (ce) is 0.490. Accuracy is 89.64%\n",
"INFO:mlp.optimisers:Epoch 13: Took 9 seconds. Training speed 320 pps. Validation speed 1681 pps.\n",
"INFO:mlp.optimisers:Epoch 14: Training cost (ce) is 0.488. Accuracy is 88.50%\n",
"INFO:mlp.optimisers:Epoch 14: Validation cost (ce) is 0.606. Accuracy is 86.87%\n",
"INFO:mlp.optimisers:Epoch 14: Took 9 seconds. Training speed 305 pps. Validation speed 1678 pps.\n",
"INFO:mlp.optimisers:Epoch 15: Training cost (ce) is 0.441. Accuracy is 88.30%\n",
"INFO:mlp.optimisers:Epoch 15: Validation cost (ce) is 0.570. Accuracy is 89.27%\n",
"INFO:mlp.optimisers:Epoch 15: Took 9 seconds. Training speed 331 pps. Validation speed 1736 pps.\n",
"INFO:mlp.optimisers:Epoch 16: Training cost (ce) is 0.478. Accuracy is 87.80%\n",
"INFO:mlp.optimisers:Epoch 16: Validation cost (ce) is 0.488. Accuracy is 90.52%\n",
"INFO:mlp.optimisers:Epoch 16: Took 9 seconds. Training speed 337 pps. Validation speed 1710 pps.\n",
"INFO:mlp.optimisers:Epoch 17: Training cost (ce) is 0.461. Accuracy is 89.60%\n",
"INFO:mlp.optimisers:Epoch 17: Validation cost (ce) is 0.736. Accuracy is 86.67%\n",
"INFO:mlp.optimisers:Epoch 17: Took 9 seconds. Training speed 294 pps. Validation speed 1678 pps.\n",
"INFO:mlp.optimisers:Epoch 18: Training cost (ce) is 0.440. Accuracy is 88.90%\n",
"INFO:mlp.optimisers:Epoch 18: Validation cost (ce) is 0.618. Accuracy is 88.99%\n",
"INFO:mlp.optimisers:Epoch 18: Took 10 seconds. Training speed 279 pps. Validation speed 1659 pps.\n",
"INFO:mlp.optimisers:Epoch 19: Training cost (ce) is 0.599. Accuracy is 87.40%\n",
"INFO:mlp.optimisers:Epoch 19: Validation cost (ce) is 0.487. Accuracy is 91.03%\n",
"INFO:mlp.optimisers:Epoch 19: Took 10 seconds. Training speed 281 pps. Validation speed 1678 pps.\n",
"INFO:mlp.optimisers:Epoch 20: Training cost (ce) is 0.447. Accuracy is 90.10%\n",
"INFO:mlp.optimisers:Epoch 20: Validation cost (ce) is 0.574. Accuracy is 89.52%\n",
"INFO:mlp.optimisers:Epoch 20: Took 10 seconds. Training speed 282 pps. Validation speed 1675 pps.\n",
"INFO:mlp.optimisers:Epoch 21: Training cost (ce) is 0.579. Accuracy is 87.80%\n",
"INFO:mlp.optimisers:Epoch 21: Validation cost (ce) is 0.550. Accuracy is 90.48%\n",
"INFO:mlp.optimisers:Epoch 21: Took 9 seconds. Training speed 302 pps. Validation speed 1678 pps.\n",
"INFO:mlp.optimisers:Epoch 22: Training cost (ce) is 0.461. Accuracy is 89.70%\n",
"INFO:mlp.optimisers:Epoch 22: Validation cost (ce) is 0.597. Accuracy is 90.02%\n",
"INFO:mlp.optimisers:Epoch 22: Took 9 seconds. Training speed 303 pps. Validation speed 1684 pps.\n",
"INFO:mlp.optimisers:Epoch 23: Training cost (ce) is 0.519. Accuracy is 89.50%\n",
"INFO:mlp.optimisers:Epoch 23: Validation cost (ce) is 0.645. Accuracy is 90.35%\n",
"INFO:mlp.optimisers:Epoch 23: Took 10 seconds. Training speed 277 pps. Validation speed 1670 pps.\n",
"INFO:mlp.optimisers:Epoch 24: Training cost (ce) is 0.439. Accuracy is 90.80%\n",
"INFO:mlp.optimisers:Epoch 24: Validation cost (ce) is 0.634. Accuracy is 90.04%\n",
"INFO:mlp.optimisers:Epoch 24: Took 10 seconds. Training speed 268 pps. Validation speed 1687 pps.\n",
"INFO:mlp.optimisers:Epoch 25: Training cost (ce) is 0.365. Accuracy is 91.50%\n",
"INFO:mlp.optimisers:Epoch 25: Validation cost (ce) is 0.564. Accuracy is 91.55%\n",
"INFO:mlp.optimisers:Epoch 25: Took 9 seconds. Training speed 309 pps. Validation speed 1733 pps.\n",
"INFO:mlp.optimisers:Epoch 26: Training cost (ce) is 0.391. Accuracy is 91.60%\n",
"INFO:mlp.optimisers:Epoch 26: Validation cost (ce) is 0.660. Accuracy is 90.20%\n",
"INFO:mlp.optimisers:Epoch 26: Took 9 seconds. Training speed 329 pps. Validation speed 1678 pps.\n",
"INFO:mlp.optimisers:Epoch 27: Training cost (ce) is 0.412. Accuracy is 91.40%\n",
"INFO:mlp.optimisers:Epoch 27: Validation cost (ce) is 0.614. Accuracy is 90.82%\n",
"INFO:mlp.optimisers:Epoch 27: Took 9 seconds. Training speed 281 pps. Validation speed 1698 pps.\n",
"INFO:mlp.optimisers:Epoch 28: Training cost (ce) is 0.470. Accuracy is 90.40%\n",
"INFO:mlp.optimisers:Epoch 28: Validation cost (ce) is 0.593. Accuracy is 91.29%\n",
"INFO:mlp.optimisers:Epoch 28: Took 10 seconds. Training speed 278 pps. Validation speed 1684 pps.\n",
"INFO:mlp.optimisers:Epoch 29: Training cost (ce) is 0.443. Accuracy is 90.90%\n",
"INFO:mlp.optimisers:Epoch 29: Validation cost (ce) is 0.623. Accuracy is 90.79%\n",
"INFO:mlp.optimisers:Epoch 29: Took 9 seconds. Training speed 309 pps. Validation speed 1661 pps.\n",
"INFO:mlp.optimisers:Epoch 30: Training cost (ce) is 0.359. Accuracy is 92.20%\n",
"INFO:mlp.optimisers:Epoch 30: Validation cost (ce) is 0.614. Accuracy is 90.74%\n",
"INFO:mlp.optimisers:Epoch 30: Took 9 seconds. Training speed 312 pps. Validation speed 1659 pps.\n",
"INFO:mlp.optimisers:Epoch 31: Training cost (ce) is 0.345. Accuracy is 92.30%\n",
"INFO:mlp.optimisers:Epoch 31: Validation cost (ce) is 0.698. Accuracy is 90.71%\n",
"INFO:mlp.optimisers:Epoch 31: Took 9 seconds. Training speed 292 pps. Validation speed 1684 pps.\n",
"INFO:mlp.optimisers:Epoch 32: Training cost (ce) is 0.443. Accuracy is 91.20%\n",
"INFO:mlp.optimisers:Epoch 32: Validation cost (ce) is 0.590. Accuracy is 91.87%\n",
"INFO:mlp.optimisers:Epoch 32: Took 9 seconds. Training speed 291 pps. Validation speed 1678 pps.\n",
"INFO:mlp.optimisers:Epoch 33: Training cost (ce) is 0.557. Accuracy is 91.00%\n",
"INFO:mlp.optimisers:Epoch 33: Validation cost (ce) is 0.624. Accuracy is 91.39%\n",
"INFO:mlp.optimisers:Epoch 33: Took 10 seconds. Training speed 277 pps. Validation speed 1687 pps.\n",
"INFO:mlp.optimisers:Epoch 34: Training cost (ce) is 0.451. Accuracy is 91.30%\n",
"INFO:mlp.optimisers:Epoch 34: Validation cost (ce) is 0.687. Accuracy is 91.12%\n",
"INFO:mlp.optimisers:Epoch 34: Took 9 seconds. Training speed 320 pps. Validation speed 1684 pps.\n",
"INFO:mlp.optimisers:Epoch 35: Training cost (ce) is 0.456. Accuracy is 91.40%\n",
"INFO:mlp.optimisers:Epoch 35: Validation cost (ce) is 0.723. Accuracy is 91.09%\n",
"INFO:mlp.optimisers:Epoch 35: Took 9 seconds. Training speed 336 pps. Validation speed 1721 pps.\n",
"INFO:mlp.optimisers:Epoch 36: Training cost (ce) is 0.379. Accuracy is 92.80%\n",
"INFO:mlp.optimisers:Epoch 36: Validation cost (ce) is 0.753. Accuracy is 90.54%\n",
"INFO:mlp.optimisers:Epoch 36: Took 9 seconds. Training speed 320 pps. Validation speed 1710 pps.\n",
"INFO:mlp.optimisers:Epoch 37: Training cost (ce) is 0.387. Accuracy is 93.10%\n",
"INFO:mlp.optimisers:Epoch 37: Validation cost (ce) is 0.721. Accuracy is 91.16%\n",
"INFO:mlp.optimisers:Epoch 37: Took 9 seconds. Training speed 306 pps. Validation speed 1692 pps.\n",
"INFO:mlp.optimisers:Epoch 38: Training cost (ce) is 0.489. Accuracy is 91.60%\n",
"INFO:mlp.optimisers:Epoch 38: Validation cost (ce) is 0.818. Accuracy is 89.82%\n",
"INFO:mlp.optimisers:Epoch 38: Took 9 seconds. Training speed 301 pps. Validation speed 1707 pps.\n",
"INFO:mlp.optimisers:Epoch 39: Training cost (ce) is 0.510. Accuracy is 91.70%\n",
"INFO:mlp.optimisers:Epoch 39: Validation cost (ce) is 0.690. Accuracy is 91.15%\n",
"INFO:mlp.optimisers:Epoch 39: Took 9 seconds. Training speed 296 pps. Validation speed 1712 pps.\n",
"INFO:mlp.optimisers:Epoch 40: Training cost (ce) is 0.560. Accuracy is 91.80%\n",
"INFO:mlp.optimisers:Epoch 40: Validation cost (ce) is 0.729. Accuracy is 91.11%\n",
"INFO:mlp.optimisers:Epoch 40: Took 9 seconds. Training speed 302 pps. Validation speed 1695 pps.\n",
"INFO:mlp.optimisers:Epoch 41: Training cost (ce) is 0.484. Accuracy is 91.50%\n",
"INFO:mlp.optimisers:Epoch 41: Validation cost (ce) is 0.629. Accuracy is 92.18%\n",
"INFO:mlp.optimisers:Epoch 41: Took 9 seconds. Training speed 325 pps. Validation speed 1689 pps.\n",
"INFO:mlp.optimisers:Epoch 42: Training cost (ce) is 0.327. Accuracy is 93.40%\n",
"INFO:mlp.optimisers:Epoch 42: Validation cost (ce) is 0.723. Accuracy is 91.48%\n",
"INFO:mlp.optimisers:Epoch 42: Took 9 seconds. Training speed 300 pps. Validation speed 1661 pps.\n",
"INFO:mlp.optimisers:Epoch 43: Training cost (ce) is 0.358. Accuracy is 93.50%\n",
"INFO:mlp.optimisers:Epoch 43: Validation cost (ce) is 0.665. Accuracy is 91.98%\n",
"INFO:mlp.optimisers:Epoch 43: Took 9 seconds. Training speed 291 pps. Validation speed 1707 pps.\n",
"INFO:mlp.optimisers:Epoch 44: Training cost (ce) is 0.441. Accuracy is 92.80%\n",
"INFO:mlp.optimisers:Epoch 44: Validation cost (ce) is 0.846. Accuracy is 90.96%\n",
"INFO:mlp.optimisers:Epoch 44: Took 9 seconds. Training speed 325 pps. Validation speed 1718 pps.\n",
"INFO:mlp.optimisers:Epoch 45: Training cost (ce) is 0.526. Accuracy is 91.10%\n",
"INFO:mlp.optimisers:Epoch 45: Validation cost (ce) is 0.674. Accuracy is 92.17%\n",
"INFO:mlp.optimisers:Epoch 45: Took 9 seconds. Training speed 317 pps. Validation speed 1710 pps.\n",
"INFO:mlp.optimisers:Epoch 46: Training cost (ce) is 0.407. Accuracy is 91.90%\n",
"INFO:mlp.optimisers:Epoch 46: Validation cost (ce) is 0.819. Accuracy is 90.26%\n",
"INFO:mlp.optimisers:Epoch 46: Took 9 seconds. Training speed 308 pps. Validation speed 1698 pps.\n",
"INFO:mlp.optimisers:Epoch 47: Training cost (ce) is 0.482. Accuracy is 92.60%\n",
"INFO:mlp.optimisers:Epoch 47: Validation cost (ce) is 0.752. Accuracy is 91.34%\n",
"INFO:mlp.optimisers:Epoch 47: Took 9 seconds. Training speed 286 pps. Validation speed 1687 pps.\n",
"INFO:mlp.optimisers:Epoch 48: Training cost (ce) is 0.405. Accuracy is 92.90%\n",
"INFO:mlp.optimisers:Epoch 48: Validation cost (ce) is 0.787. Accuracy is 91.25%\n",
"INFO:mlp.optimisers:Epoch 48: Took 10 seconds. Training speed 279 pps. Validation speed 1672 pps.\n",
"INFO:mlp.optimisers:Epoch 49: Training cost (ce) is 0.597. Accuracy is 91.70%\n",
"INFO:mlp.optimisers:Epoch 49: Validation cost (ce) is 0.794. Accuracy is 91.60%\n",
"INFO:mlp.optimisers:Epoch 49: Took 9 seconds. Training speed 285 pps. Validation speed 1698 pps.\n",
"INFO:mlp.optimisers:Epoch 50: Training cost (ce) is 0.472. Accuracy is 93.30%\n",
"INFO:mlp.optimisers:Epoch 50: Validation cost (ce) is 0.918. Accuracy is 90.65%\n",
"INFO:mlp.optimisers:Epoch 50: Took 9 seconds. Training speed 303 pps. Validation speed 1672 pps.\n",
"INFO:root:Testing the model on test set:\n",
"INFO:root:MNIST test set accuracy is 90.79 %, cost (ce) is 0.898\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"The autoreload extension is already loaded. To reload it, use:\n",