# Article that explains using Flux on MNIST from the model-zoo example

**URL:** https://discourse.julialang.org/t/article-that-explains-using-flux-on-mnist-from-the-model-zoo-example/16295
**Category:** Machine Learning
**Created:** [October 13, 2018, 10:45pm UTC](https://discourse.julialang.org/t/article-that-explains-using-flux-on-mnist-from-the-model-zoo-example/16295 "2018-10-13T22:45:19Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![microgold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/microgold/32/5404_2.png) [@microgold](https://discourse.julialang.org/u/microgold)
#### Post date: [October 13, 2018, 10:45pm UTC](https://discourse.julialang.org/t/article-that-explains-using-flux-on-mnist-from-the-model-zoo-example/16295/1 "2018-10-13T22:45:19Z")

</div>

I created an article that attempts to explain the Flux example of a Convolutional Neural Network operating on the MNIST set. The article goes through each line and explains what its doing in Julia. I’d appreciate any input on making it clearer for developers wanting to get into deep learning.

> **[Creating a Deep Neural Network Model to Learn Handwritten Digits using Julia](https://www.linkedin.com/pulse/creating-deep-neural-network-model-learn-handwritten-digits-mike-gold/)**
>
> Introduction In the previous article we discussed how to manipulate dataframes and train a Random Forest model to help classify the species of irises. In this article we will use a library in Julia called Flux, that will allow us to build a...

---

<div class="post-metadata">

### Author: ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)
#### Post date: [October 26, 2018, 9:17pm UTC](https://discourse.julialang.org/t/article-that-explains-using-flux-on-mnist-from-the-model-zoo-example/16295/2 "2018-10-26T21:17:50Z")

</div>

Nice write-up! There is only one part that I find a little confusing (I’m a deep learning noob, so it may be something obvious). The performance after training the network in what seems like the standard way, that is to say `Flux.train!(loss, train, opt, cb = evalcb)` is OK but not spectacular (56% compared to a chance level of 10%). Yet you mention that:

> If we run the data through 10 times, we start to approach accuracies of 96%

What does that mean exactly? You are calling the same function `Flux.train!(loss, train, opt, cb = evalcb)`, you are passing different training datasets to the network, or something else? I find it confusing because if somehow the performance is suboptimal after the initial training because the training was not enough, I would expect some keyword in the `train!` function to specify when to stop training.

---

<div class="post-metadata">

### Author: ![microgold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/microgold/32/5404_2.png) [@microgold](https://discourse.julialang.org/u/microgold)
#### Post date: [October 26, 2018, 9:38pm UTC](https://discourse.julialang.org/t/article-that-explains-using-flux-on-mnist-from-the-model-zoo-example/16295/3 "2018-10-26T21:38:00Z")

</div>

Thanks Piever,

I appreciate you taking the time to give insightful feedback. It approaches 96% accuracy after running the same dataset (60,000 images) through 10x. I suspect you would see a similar convergence if you ran 10 different MNIST datasets through. It just takes a lot of data for the neural network to perform enough error correction in the weights to start to improve the ability of the model to classify the images.

---

<div class="post-metadata">

### Author: ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)
#### Post date: [October 27, 2018, 3:49am UTC](https://discourse.julialang.org/t/article-that-explains-using-flux-on-mnist-from-the-model-zoo-example/16295/4 "2018-10-27T03:49:44Z")

</div>

The `train!` function just loops once through the data. Running the same `train!` function with the same data several times will improve the result.

---

<div class="post-metadata">

### Author: ![microgold](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/microgold/32/5404_2.png) [@microgold](https://discourse.julialang.org/u/microgold)
#### Post date: [October 27, 2018, 5:24am UTC](https://discourse.julialang.org/t/article-that-explains-using-flux-on-mnist-from-the-model-zoo-example/16295/5 "2018-10-27T05:24:43Z")

</div>

That is correct, in the notebook, I ran the Flux.train! function 10 times on the same MNIST data to get to 96% accuracy. Thanks for clarifying, dpsanders. I’ll try to make that clearer in the article.
