T
Trask
iamtrask.github.io · Personal blog · on HN since 2014
Andrew Trask writes about machine learning, with from-scratch Python neural network tutorials, plus posts on encrypted deep learning and word2vec.
What HN saysHN commenters recommend it for its simple 11-line Python neural network example and list it among deep learning blogs worth following.
21HN people shared it
14linked it in comments
39stories submitted
2.2Kstory points
7 months agolast shared
2014people per year2026
Most-shared posts
- 1A Neural Network in 11 Lines of Python13 people · 701 points · first shared 2015 · 41 comments on HN
- 2How to Code and Understand DeepMind's Neural Stack Machine3 people · 24 points · first shared 2016 · discussion on HN
- 3A neural network in 13 lines of python (Part 2 - Stochastic Gradient Descent)3 people · 19 points · first shared 2015 · discussion on HN
- 4I am Trask: machine learning craftsmanship blog3 people · 1 points · first shared 2017 · discussion on HN
- 5Grokking Deep Learning2 people · 530 points · first shared 2016 · 112 comments on HN
- 6Safe Crime Prediction: Encrypted Deep Learning for Less Intrusive Surveillance2 people · 51 points · first shared 2017 · 49 comments on HN
- 7Building Safe AI: A Tutorial on Homomorphically Encrypted Deep Learning1 people · 228 points · first shared 2017 · 95 comments on HN
- 8How to Code and Understand DeepMind's Neural Stack Machine in Python1 people · 198 points · first shared 2016 · 16 comments on HN
- 9Deep Learning without Backpropagation1 people · 140 points · first shared 2017 · 12 comments on HN
- 10Anyone Can Learn to Code an LSTM-RNN (Part 1: RNN)1 people · 133 points · first shared 2015 · 14 comments on HN
- 11Deep Learning with PyTorch – An Unofficial Startup Guide1 people · 84 points · first shared 2017 · 15 comments on HN
- 12Distributing a Fully Connected Neural Network Across a Cluster1 people · 30 points · first shared 2014 · 6 comments on HN
- 13Tutorial: when Numpy isn't fast enough...1 people · 15 points · first shared 2014 · discussion on HN
- 14Tutorial: Apache Spark on GPU(s)1 people · 12 points · first shared 2014 · 2 comments on HN
- 15A Neural Network in 11 Lines of Python1 people · 11 points · first shared 2017 · discussion on HN
What HN people wrote when they linked it
emilwallner · 2017-10-13
I'm also starting to follow people and communities that work with deep learning in new ways. Here are some of my favorites:
[1] http://colah.github.io/
[2] https://iamtrask.github.io/
[3] https://distill.pub
[4] https://experiments.withgoogle.com/ai
alexpotato · 2025-05-05
If people like "give me the simplest possible working coding example" of neural networks, I highly recommend this one:
"A Neural Network in 11 lines of Python (Part 1)": https://iamtrask.github.io/2015/07/12/basic-python-network/
striker_axel · 2020-02-06
For interesting reads in Deep learning I follow these:
- https://distill.pub/
- http://colah.github.io/
- https://lexfridman.com/ai/
- http://iamtrask.github.io/
And some interesting reads on Uncertainty in Deep Learning
http://mlg.eng.cam.ac.uk/yarin/blog_2248.html
bko · 2016-12-26
An alternate theory is that you can make use of ML to do useful tasks through an understanding of just high school math (basic algebra) and basics of python. I'm not sure if that's actually true, but I'm inclined to be in this camp as abstractions are used in virtually every other tasks. The amount of extra value that can be had from applying even basic ML techniques is so great, that there is probably a lot of upside to using ML even if they're only able to hire practitioners.
A great resource specifically tailored to those that don't have a especially strong grasp of probability and statistics is Grokking Deep Learning
https://iamtrask.github.io/2016/08/17/grokking-deep-learning/
ageitgey · 2018-02-15
This is a very poor article. It manages to both be demeaning to people who want to learn something new while also being riddled with factual errors.
Here are just a few factual errors:
1. The 11-line example is the simplest possible neural network with a very basic implementation of gradient descent in a high-level vectorization framework (numpy). It's exactly what you'd cover in the first week of a course on neural nets. But obviously there are many things to learn beyond that before you can solve real problems effectively with neural nets. In fact, the example code is 100% lifted from Hacker News user williamtrask's great article [1] which ironically closes with a list of 10 topics to investigate next to start learning the additional things you'd need to make your neural net useful for real problems.
2. This section:
> '“Deep Learning” and n-Layers of depth is just a neural network that runs its output through itself. This is called Recursive Neural Networks (RNN), because you loop the loop.'
..is full of errors. RNNs are Recurrent, not Recursive. They have nothing to do with having more layers, but with having a memory of previous states. And in deep learning, having more layers is often a strategy to reduce the dimensionality of the input and learn higher-level representations of data by using a variety of tricks/layer types/connections. It's not just "looping the loop".
3. The whole section about not initializing the random state and thus getting different results…
landon32 · 2017-07-29
Yes for sure. I am very math-averse (almost failed calculus 1, skated by pre-calc in high school... not my intelligence area) and though I don't have a full time job doing something in AI, I do feel like I can build models that solve real problems (and am doing so in an internship right now).
Probably start with Andrew Ng's Machine Learning course. It has a significant amount of Math in it-- try to understand it, but seriously do not worry about it. Just get the high level concepts, try to get some intuition on machine learning ideas and techniques. You don't need to do the assignments or work too hard on the course (but obviously it's helpful if you do).
Then read these. Don't worry if you're still confused at first. It's fine. Just go through 'em kinda slowly and try to see what's going on.
https://iamtrask.github.io/2015/07/12/basic-python-network/
http://karpathy.github.io/neuralnets/
By now if you're still into it, I highly recommend Chris Olah's blog: http://colah.github.io/
It has some pretty complicated ideas in there, but the articles are illustrated and explained very well so you can get more of a feel for Neural Networks while also getting very excited about them.
Then it's probably time to start really building things. I would use Keras (https://keras.io/) at first, because it's very easy to get cool results without understanding everything under the hood. Do a tutorial or two, it's pretty intuitive and if you've done everything above you should understand…
etienne89 · 2024-07-11
That reminds me of the article „a neural network in 11 lines of code“ from 2015 (although not on MNIST, rather some kind of XOR)
https://iamtrask.github.io/2015/07/12/basic-python-network/
iamaziz · 2019-03-06
The visualization is cool, thanks!
Here's another neural network example from scratch in 13 lines of Python:
https://iamtrask.github.io/2015/07/27/python-network-part2/
apetrov · 2017-11-26
I had a really good time adapting Karpatny's blog post to python myself but it didn't give me sufficient understanding so i continued with [1], then [2] and finally deciphering [3].
[1] https://mattmazur.com/2015/03/17/a-step-by-step-backpropagation-exampl…
[2] http://peterroelants.github.io/posts/neural_network_implementation_par…
[3] https://iamtrask.github.io/2015/07/12/basic-python-network/
ghosthamlet · 2017-07-31
The original Python implemation found at: http://iamtrask.github.io/2015/07/12/basic-python-network/
X =: 4 3 $ 0 0 1 0 1 1 1 0 1 1 1 1
Y =: 4 1 $ 0 0 1 1
w =: 3 1 $ 0.5069797399 0.5703818579 0.9265880619
e =: 2.718281828459045
iter =: ^:
dot =: +/ . *
T =: |:
output =: verb define
1 % 1 + e ^ 0 - X dot y
)
train =: verb define
l1 =: output y
l1_err =: Y - l1
l1_delta =: l1_err * l1 * 1 - l1
y + (T X) dot l1_delta
)
w =: (train iter 1000) w
l1 =: output w
l1
iamtrask · 2016-03-28
Per your last comment, I'm thinking about changing this blog series to be a "blog" version of academic papers... starting with this one.
https://iamtrask.github.io/2016/02/25/deepminds-neural-stack-machine/
bjourne · 2015-12-02
Did you forget the link? :) http://iamtrask.github.io/2015/07/12/basic-python-network/
digisth · 2015-12-04
The below resources are the ones I used when I started to learn about DL/NNs. Some of them are focused specifically on certain applications, but I found them helpful, too.
Basic NNs:
http://www.wildml.com/2015/09/implementing-a-neural-network-from-scrat… (a whole series, all worth reading)
https://gist.github.com/sthware/c47824c116e6a61a56d9 (my code based on the above)
http://iamtrask.github.io/2015/07/27/python-network-part2/
http://rolisz.ro/2013/04/18/neural-networks-in-python/
ML:
http://cs229.stanford.edu/materials.html
http://onlinestatbook.com/2/index.html
DL in general, RNNs, RNTS, CNNs, some others:
http://cs224d.stanford.edu/syllabus.html
http://cs231n.stanford.edu/syllabus.html
http://mattmazur.com/2015/03/17/a-step-by-step-backpropagation-example…
http://arxiv.org/pdf/cs/0205070.pdf
http://colah.github.io/posts/2015-08-Understanding-LSTMs/
http://karpathy.github.io/2015/05/21/rnn-effectiveness/
http://nlp.stanford.edu/~socherr/EMNLP2013_RNTN.pdf
http://alexdavies.net/talks/
http://www.socher.org/index.php/Main/SemanticCompositionalityTh
roughRecursiveMatrix-VectorSpaces
http://colah.github.io/posts/2014-03-NN-Manifolds-Topology/
http://colah.github.io/posts/2014-07-NLP-RNNs-Representations/
dr_zoidberg · 2015-07-29
They are, but once you start learning about them, you realize the "black magic" part comes mostly from their mathematical nature and very little from them being "inteligent computers".
A neural net is a graph, in which a subset of nodes are "inputs" (that's where the net gets information), some are outputs, and there are other nodes which are called "hidden neurons".
The nodes are interconnected between each other in a fashion, which is called the "topology" or sometimes "architecture" of the net. For example I-H-O is a tipical feed forward net, in which I (inputs) is the input layer, H is the hidden layer and O the output layer. All the hidden neurons connect with all the input neurons "output", and all the output neurons connect to the hidden neurons "output". The connections are called "weights", and the training adjusts the weights of all the neuron with lots of cases until the desired output is achieved. There are also algorithms and criteria to stop before the net "learns too much" and looses the ability to generalize (this is called overfitting). In particular, a net with one hidden layer and one output layer is a universal function estimator -- that is, an estimator that can model any mathematical function of the form f(x1, x2, x3, ..., xn) = y.
Deep learning means you're using a feedforward net with lots of hidden layers (I think it's usually between 5 to 15 now), which apply convolution operators (hence the "convolutional" in the name), and lots of neurons (in…