Live data from Hacker News

Implementing a Neural Network from Scratch in Python

victorzhou.com

51–60 of 104 posts

Re: Implementing a Neural Network from Scratch in Python

#51

"We’ll use an optimization algorithm called stochastic gradient descent (SGD) that tells us how to change our weights and biases to minimize loss. It’s basically just this update equation: w1 ← w1 − η ∂w|∂L η is a constant called the learning rate that controls how fast we train. All we’re doing is subtracting η ∂w|∂L from w1: - If ∂L | ∂w1 is positive, w1 will decrease, which makes L decrease - If ∂L | ∂w1 is positi…

I think this comment is facetious (apologies if I’m reading it incorrectly), so I want to offer that this is “simple”, but opaque to someone who is unfamiliar with the syntax or background context. Andrew Ng’s course on machine learning from Stanford (on Coursera, which you should be able to audit for free) gives great intuitive explanations of these topics, if you’re curious enough to invest a couple solid weekends…

Seconding Ng's course here.

I took it in 2011 (ML Class) before Coursera existed, and it finally opened my eyes on not only what and how backprop worked, but also how everything in a NN could be represented and calculated using vectors and matrices (linear algebra), and how that process was "parallelizable".

The course uses Octave as it's programming environment, which is essentially an open-source and (mostly) compatible implementation of Matlab.

My first thought was "Finally! A use case for a home Beowulf cluster that is somewhat practical!"

It really opened my eyes and mind to a number concepts that I had looked into before, but couldn't quite wrap my brain around completely.

Re: Implementing a Neural Network from Scratch in Python

#52
post #32

Why are deep learning researchers allergic to meaningful variable names?

They're usually working from text/notes in mathematical notation and are trying to match the math notation as best they can. I'm sure programming not being their profession may be part of it, but I find myself doing the same thing when implementing algorithms described in mathematical notation. Due to the shear number of variables in a lot of algorithms, it's difficult to give each one a good name. And even if you did, it's unlikely the code would make any more sense, in order to grasp what's going on, you'd likely need some text on the subject to explain how it works.

Re: Implementing a Neural Network from Scratch in Python

#54
One of the nice parts of NNs is that it takes some maths education to understand what's going on. My initial thought when reading the title was: "uh oh, are AI tutorials going to be the next PHP/MySQL tutorials, with god awful code all over the internet?" They haven't yet insofar as I'm aware. I hope the maths involved will prevent them from becoming that.

Re: Implementing a Neural Network from Scratch in Python

#55

Earlier quoted context omitted.

Still got it somewhere? I've got a project to demonstrate a bunch of Hypercard stacks in a retro-computing context, and it'd be definitely interesting to see, in the case that you'd consider finding it and sharing it ...

Oh gosh.... that was so many years ago. I suspect I could never find the floppy, assuming I haven't chucked it. All I can remember about it is that it was structured to ask the user one query per card, and there was some kind of global function that kept the state of the consultation and navigated to the next card. The expert system that I implemented was a simple toy, because the point was to explore the UI aspects.…

Well, it was worth the try .. sounds interesting though! There's a resurgent interest in Hypercard these days .. if you ever get the druthers to go look for your old stack, I'm sure it'll be of interest to some of us. :)

Re: Implementing a Neural Network from Scratch in Python

#56
post #32

Why are deep learning researchers allergic to meaningful variable names?

I've found that lots of people from math backgrounds are comfortable with non-descriptive variable names. Most variables in math are Greek letters, or "i, j, k" and things like that.

Re: Implementing a Neural Network from Scratch in Python

#57
post #5

Great, but the problem with these summaries is no real-world data/use-case. An actual business case example with code is easier to comprehend for less math-inclined folks.

The problem with that is these kinds of simplified "how it works" neural net examples don't scale for real world problems - especially when using an interpreted language like Python.

Even a simple but useful scenario like the MNIST number recognition system would probably run "dog-slow" on such a neural network, given the number of input nodes, plus the size of the hidden layer - the combinatorial "explosion" of edges in the graph, all the processing needed during backprop and forwardprop...

It might be doable with C/C++ - but it still won't run as well as it could.

These examples are really just meant as teaching tools; they are the bare-bones-basics of neural networks, to get you to understand the underlying mechanisms at work (actually, the XOR network is the real bare-bones NN example, because it requires so few nodes, that it can be worked out by pencil and paper methods).

Real-world implementations are best done using more advanced libraries and tools, like Tensorflow and Keras, or similar (and moving to C/C++ and/or CUDA if even more processing power is needed).

Re: Implementing a Neural Network from Scratch in Python

#60
post #32

Why are deep learning researchers allergic to meaningful variable names?

These are meaningful variable names in the context of a code implementation of a math algorithm. The variables directly map to the algorithmic notation.

And when trying to do algebraic manipulation on paper, having an 8 or 10 letter variable name is incredibly cumbersome.

Frankly in the middle of a numerical algorithm it is typically also cumbersome in code to have descriptive variable names for everything.

However, mathematical code (especially when written by scientists, etc.) often takes this too far, introducing many 1- or few-letter variable names without enough context or description to figure out what they stand for, and for more of the variables than necessary.

This blog post was just fine though. h = hidden, o = output, y_pred = predicted value of y, etc. are quite clear

Post reply on HN