# Simple NN from scratch

**URL:** <https://discourse.julialang.org/t/simple-nn-from-scratch/22984>\
**Category:** New to Julia\
**Tags:** optimization\
**Created:** [April 10, 2019, 2:42am UTC](https://discourse.julialang.org/t/simple-nn-from-scratch/22984 "2019-04-10T02:42:17Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sairus7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sairus7/32/10816_2.png) [@sairus7](https://discourse.julialang.org/u/sairus7)\
**Post date:** [April 10, 2019, 2:42am UTC](https://discourse.julialang.org/t/simple-nn-from-scratch/22984/1 "2019-04-10T02:42:17Z")

</div>

Just published a simple example script of neural network [simpleNN.jl](https://github.com/sairus7/simpleNN.jl) from the original post: [macOS Python with numpy faster than Julia in training neural network](https://stackoverflow.com/questions/49719076/macos-python-with-numpy-faster-than-julia-in-training-neural-network).

There are a lot of optimization tips in the original answer from @ChrisRackauckas, that are implemented in the first version of the script. Some additional sequental changes and improvements are shown in versions 2-4. And the point is, when I use matrix multiplication (v3), training epoch becomes x10 faster.

---

<div class="post-metadata">

**Author:** ![charlesll](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/charlesll/32/3255_2.png) [@charlesll](https://discourse.julialang.org/u/charlesll)\
**Post date:** [April 10, 2019, 3:04am UTC](https://discourse.julialang.org/t/simple-nn-from-scratch/22984/2 "2019-04-10T03:04:45Z")

</div>

Do you know how the same problem coded using Flux compare in term of time/efficiency?

---

<div class="post-metadata">

**Author:** ![sairus7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sairus7/32/10816_2.png) [@sairus7](https://discourse.julialang.org/u/sairus7)\
**Post date:** [April 10, 2019, 12:41pm UTC](https://discourse.julialang.org/t/simple-nn-from-scratch/22984/3 "2019-04-10T12:41:20Z")

</div>

This is the closest example (with quite different architecture):  
[https://github.com/FluxML/model-zoo/blob/master/vision/mnist/mlp.jl](https://github.com/FluxML/model-zoo/blob/master/vision/mnist/mlp.jl)  
However, I didn’t test it with batch processing.
