tensorflow / playground

Play with neural networks!
http://playground.tensorflow.org
Apache License 2.0
11.97k stars 2.55k forks source link

Documentation/feature request: could you explain the hidden nodes a bit more? #126

Open PenelopeFudd opened 4 years ago

PenelopeFudd commented 4 years ago

In the section named "What Do All the Colors Mean?", there's this paragraph: "In the hidden layers, the lines are colored by the weights of the connections between neurons. Blue shows a positive weight, which means the network is using that output of the neuron as given. An orange line shows that the network is assiging[sic] a negative weight."

Thanks!

atharva-sundge commented 4 years ago

Hidden layers extracts increasingly abstract features from the image. These layers are called “hidden” because their values are not given in the data; instead the model must determine which concepts/features are useful for explaining the relationships in the observed data.

PenelopeFudd commented 4 years ago

That's great: now could something like that be added to the help text on the page?

I'd argue that a help text document isn't complete unless absolutely everything on the screen is explained. A person could go look at the linked web resources or the source code to work out any answers that aren't there, but to educate the most people, it's better if the answers are right there in the help text.

For instance, "the nodes have a real number value, the links have a weight (another real number), and the calculation to find a node's value is 'for each input link, multiply the inputs by their respective weights and sum them'" (or whatever the formula is). However, that doesn't explain how the 2d graphs on each node are generated, and I think that's the coolest thing. :-)

That's why I was reading the help text in the first place: to find out how the 2d graphs are calculated.

atharva-sundge commented 4 years ago

Fine. 3blue1brown named channel on youtube is very good to get intuition of different concepts, also NN.

mars0i commented 4 years ago

I am very interested the playground because I want to use it to teach basic NN concepts to students in my philosophy of cog sci class. What's great about the playground page is that you can see the hidden nodes and weights update in real time. That's just what I need for teaching. However, I am very puzzled by some of the features, and just a little bit more documentation would help a lot. I certainly am not a NN expert, but I've written NNs by hand and have understood basic concepts of NNs for years. I just went to the 3blue1brown channel, and what it seems to have are videos about general NN concepts, rather than anything that would answer my questions about the playground.

I have some specific questions that I can't answer for myself without thorough study of the source code, but I think they should be relatively easy questions to answer without studying the source. You will see that I have some hypotheses about what is meant by aspects of the display, but I am not sure. (If I can understand the answers to these questions, I'd happily volunteer to write up the answers nicely and contribute documentation.)

EDIT: Updating with proposed answers as I figure them out.

  1. Am I correct that the system use some kind of backpropagation? [My answer: yes.]

  2. Why are the displays for the things called "neurons" two-dimensional? Traditionally, a neuron is real-valued. Do the little squares represent arrays of nodes? i.e. what the display refers to as a neuron is really an array of real-valued nodes (or what I would call neurons)? So if there are two squares in layer, does that mean that there are two arrays of nodes? (The pixels in the squares can't represent inputs; there are two many pixels and too few weight liines.)

    [Start of my answer: The Node class in nn.ts has a totalInput and an output that are numbers, so the Nodes at least are not arrays. Are there arrays of Nodes? Yes: see updateDecisionBoundary() in playground.ts.]

  3. Suppose I have only one hidden layer. If the squares represent arrays, is the idea that each node (n,m) in the output layer is connected to the corresponding nodes at (n,m) in each array in the hidden layer, and each node at (n,m) is connected to the (n,m) node in each of the input arrays?

  4. Since the weight lines are just single lines, does that mean that the backprop algorithm (if that's what it is) weights all links between two arrays the same way--i.e. the connection between (n,m) in array A and (n,m) in array B is the same for all coordinates (n,m)?

  5. There is a checkbox that allows one to display "test data". When is this used? There doesn't seem to be a separate training step.

Thank you! This is a great tool. I don't know of any other site or application that could be as useful for teaching as this one. On the other hand, if I don't understand what it's doing, it's difficult to use for teaching.

mars0i commented 4 years ago

I just read issue #96. I can't figure out whether it answered my questions or not. (The video linked there is great--I will probably assign it to my students--but it doesn't answer my questions about the playground page.)

mars0i commented 4 years ago

Here is a hypothesis that is relevant to my earlier question number 5. Weights change when you run the system, but the classification of the test data also changes. Changing weights should be the result of training, while classification on new data is what happens after you've done the training. So my current hypothesis is that the weights (and biases) are changing due to the training data (which is hidden by default but can be revealed using the checkbox), and after each training run (or each batch, according to the batch size slider?) the network tries to classify the test data. So we see the weights updating due to training and also get interim reports on how far the network has gotten toward being a good at classifying the test data. However, the test data has no effect on the weights.

A further question is whether the colorings of the little "neuron" boxes are changing in direct response to training, or in response to the test data given the current values of the weights and biases. I think it must be the latter.

When one clicks on the "reset the network" icon, the link weights change. I assume that these are random weights, rather than some response newly created data.

[Yes--weights are initially random by default. See class Link in nn.ts.]

mars0i commented 4 years ago

This looks useful. Haven't read it yet: https://cloud.google.com/blog/products/gcp/understanding-neural-networks-with-tensorflow-playground