I BUILT A NEURAL NETWORK IN MINECRAFT | Analog Redstone Network w/ Backprop & Optimizer (NO MODS)
deep learning machine learning neural networks ai artificial intelligence minecraft neural networks explained what is deep learning deep learning tutorial introduction to deep learning deep learning in minecraft minecraft machine learning redstone neural network minecraft redstone neural network gaming neural network neural network explained machine learning in minecraft vanilla minecraft computer minecraft vanilla redstone computer minecraft backpropagation
#minecraft #neuralnetwork #backpropagation

I built an analog neural network in vanilla Minecraft without any mods or command blocks. The network uses Redstone wire power strengths to carry the signal through one hidden layer, including nonlinearities, and then do automatic backpropagation and even weight updates.

OUTLINE:
0:00 - Intro & Overview
1:50 - Redstone Components Explained
5:00 - Analog Multiplication in Redstone
7:00 - Gradient Descent for Square Root Computation
9:35 - Neural Network Demonstration
10:45 - Network Schema Explained
18:35 - The Network Learns a Datapoint
20:20 - Outro & Conclusion

I built this during a series of live streams and want to thank everyone who helped me and cheered for me in the chat!

World saves here: https://github.com/yk/minecraft-neural-network
Game here: https://www.minecraft.net
Multiplier Inspiration: https://www.youtube.com/channel/UCLmzk4TlnLXCXCHcjuJe2ag

Credits to Lanz for editing!

Links:
TabNine Code Completion (Referral): http://bit.ly/tabnine-yannick
YouTube: https://www.youtube.com/c/yannickilcher
Twitter: https://twitter.com/ykilcher
Discord: https://discord.gg/4H8xxDF
BitChute: https://www.bitchute.com/channel/yannic-kilcher
Minds: https://www.minds.com/ykilcher
Parler: https://parler.com/profile/YannicKilcher
LinkedIn: https://www.linkedin.com/in/yannic-kilcher-488534136/
BiliBili: https://space.bilibili.com/1824646584

If you want to support me, the best thing to do is to share out the content :)

If you want to support me financially (completely optional and voluntary, but a lot of people have asked for this):
SubscribeStar: https://www.subscribestar.com/yannickilcher
Patreon: https://www.patreon.com/yannickilcher
Bitcoin (BTC): bc1q49lsw3q325tr58ygf8sudx2dqfguclvngvy2cq
Ethereum (ETH): 0x7ad3513E3B8f66799f507Aa7874b1B0eBC7F85e2
Litecoin (LTC): LQW2TRyKYetVC8WjFkhpPhtpbDM4Vw7r9m
Monero (XMR): 4ACL8AGrEo5hAir8A9CeVrW8pEauWvnp1WnSDZxW7tziCDLhZAGsgzhRQABDnFy8yuM9fWJDviJPHKRjV4FWt19CJZN9D4n
 I built a fully functional, trainable, analog neural network in Minecraft with no command blocks and no mods. Check this out. Hello? Hello? Hi. Hi. I'm... I'm trying to build a neural net... Hi, I'm trying to build a neural network. Hi. Can you please... I don't want to buy your stuff. I'd like... No, I don't want a bucket of... No, I don't want a bucket of puffer fish. What you're seeing here is an analog neural network. While lots of people build binary computers in Minecraft, this neural network works in an analog fashion. It means it works directly with the signal strength on these wires right here. It has two layers, and it has two neurons in its hidden layer. It computes an output. It compares that output against the target. It back propagates the error back through the network. And it is even able to update its own weights in response. So it can fully autonomously learn any function that you want. So today I'm going to show you how I built this, how it works, and what could potentially be improved. Be sure to like this video, and let me know what you think in the comments. So the output is nine, and now I change the input back to the last data point. The max operation is actually released. Yes, but the org max isn't, right? It's six. He learned two data points. He learned two data points. He learned two data points. So this whole network runs on Redstone. Redstone is a concept in Minecraft that is a little bit like electricity. You can see right here the torch emits a signal, and it is transmitted across these wires in red right here. Now, the property of Redstone is that it starts out with a signal strength of 15, as you can see indicated by these lights. And for each distance that it travels, it drops by one signal strength. Now, most people simply use the on or off state of these wires as binary signals, and build computer out of that. However, I decided I wanted to use the signal strength directly as a signal, and build a neural network based on that. This gives us a much more compact neural network, and it is much more akin to how we build neural networks in machine learning, and also in the brain. Next, I'm going to show you the main components that we use to build this neural network. This here is a lector, and the building block right behind it is called a comparator. Now, the comparator has the ability to read signal from blocks before it. In this case, it reads the page of the book that is on the lector, here 9, and translates that into a Redstone signal. You can see the Redstone signal is 9 strong at the beginning, and decays with each distance traveled. Parators are actually a special block in Redstone, in that they can transmit a signal without it losing its strength over distance. In this demonstration, you can see the difference between a comparator and what is known as a repeater. The comparator simply transmits the signal one block and keeps its strength, while the repeater will fully power up the signal back up to 15, no matter what signal comes in. Only when a signal of 0 comes in is the repeater fully off. Another interesting fact about comparators is the fact that they can be used for doing math. In particular, they can do subtraction. Here we subtract the side signal from the main signal, which results in a resulting signal of strength 2. Note that this comparator is in subtraction mode, because its front light lights up. This neat thing right here is a divider. It divides the signal by 4, which is pretty cool. Since the Redstone signal is capped at 0 at the lower end and 15 at the higher end, we don't really have a lot to work with. Dividing by 4 is often useful to bring the signal back to a manageable range. So this would bring the signal from 0 to 15 to a range of 0 to 3, or 1 to 4, however we want it. The most important building block in a neural network is going to be what's known as a memory cell. This is a memory cell. It consists of two comparators, each feeding into a block, and each block powering a cable that then feds into the comparator again. This is a closed loop, and it will save any state that you give it. I can fully charge it with this button, and I can fully de-charge it with this button. A slight variation on the memory cell is the decaying memory cell, which I think is pretty cool. It is almost like a memory cell, but since this wire here is of length 2, it de-charges by 1 every time the signal goes around the cycle. So if I fully charge it, what you're going to see is that it slowly decays over time. Let me show that again. This is pretty cool. This is a multiplier. It is a device that can multiply two analog signals, and it is really cool how that works. It combines the memory cell and the decaying memory cell to achieve this multiplication. Again, the multiplication is in analog here, and not in binary. The design is from a YouTube channel called RKFValter, and I didn't come up with this myself, and it took me quite a while to understand what was going on. Though once I had it, I was able to build the rest of the neural network almost without a problem. At the bottom, you'll find a single memory cell that stores 15 minus whatever we want as an output. The signal is then fed into this comparator, which is in subtraction mode, and feeds from this hopper that is full. So the output is going to be here. On top of the memory cell, you'll find a decaying memory cell. The decaying memory cell powers this piston here, and it is fed via an ultra-short tick of this piston with this signal. This is one of our two input signals. As long as the decaying memory cell is active, this piston stays down. As long as this piston is down, our second input is fed through this circuit into the memory cell at the bottom and is subtracted. That means the bottom signal is subtracted from this memory cell an amount of times that is proportional to how long the piston stays down. This, as you can see, results in a multiplication of the two analog signals. Pretty cool. Here I use this to multiply the two numbers, two and three, as you can see by the pages of the book. As soon as I hit the button, the memory cell is reset, an ultra-short pulse is generated, and this piston stays down just long enough for the de-charge to happen an appropriate amount of times. You can see the result is six. And if I change this to a larger number, say five, you can see that the piston now stays down for much longer than before. Of course, we can only handle signals up to 15 even with this contraction. The last thing we need is gradient descent. By combining a multiplier and a memory cell together with two pistons that update the memory cell, we can achieve gradient descent. This here was my test application for gradient descent. It is a square root finder, and to my knowledge, it is also the first analog square root finder that is implemented in Minecraft Redstone. Innovation happening on this channel every day. So the way it works is that we have a memory cell that we can update using either this piston or this piston. We can update it up or down. We feed the signal from the memory cell as the first and the second multiplicand into the multiplier. The two numbers are then multiplied together and come out here. On this lectern, we set a target that we would like to know the square root of. In this case, I want to know the square root of the number nine. This circuit right here then calculates an error signal and tells the contraction down here whether we need to go up or down with our memory cell. Depending on that, either this piston or this piston is activated with an ultra short pulse, and we change the memory cell by one or negative one. If we repeat this cycle, eventually we should converge to the square root of whatever we input into this lectern. So if I hit the button right here, square is calculated, the error is calculated, the memory cell is updated, and you can see one is our first guess. Let's hit the button again and see what happens. We're at two. Now we're at three. If we hit the button again, we do expect the network to converge. So you can see there was no more update. So now we have converged on three, which is, of course, as you know, the square root of nine. If we input any other number than a pure square, the network is going to oscillate between the two square roots that are closest in integer. So here two, and now it oscillates back to three. Gradient descent in Minecraft. Thank you. The neural network is a bit more complicated in that it can not only do gradient descent by plus one or negative one, it will actually calculate the exact error signal that comes back from the front. It will calculate it through the nonlinearity, and it even has adjustable learning rates. All right, now let's try it out. So in this neural network, what you do is you use these two books to set the input signals for each of the two input dimensions. In this case, it's one and three. And you use this book to set the target value. In this case, I've set it to 12. That's a bit high. Let's set that to six. Once I hit this button, the whole operation starts in full automatic mode. Let's go. So what you're going to see is the signal forward traveling through the network, through the first layer, into the second layer, which you're going to see right now. After that, the output is going to be displayed after a short flicker on this pole right here. Now this happens to be exactly correct. It's not always the case. After this, the network flips into back prop mode, at which point the signal is traveling backward through the second layer to the first layer. At the end, this piston there is going to hit, which is going to implement the weight update given by these upper pistons right now. And after all of that, the control signal travels back and we start again. Let me show you a little bit more clearly what happens in each step. The neural network we're going to build here has two input neurons, which can be loaded with a value of anywhere between one to 15. This is followed by another layer of neurons. Two neurons form the hidden layer of the network and yet another layer, one neuron forms the output. Each layer is a fully connected layer, which means that every neuron in the layer before is connected to every neuron in the layer above. And the same goes for the second layer. Each of these layers has a weight associated with it. The back propagation formulas tell us how the signal flows forward in the network and also how the signal flows backward, while the optimizer formula is telling us how we need to update the weight once we have computed the back propagation signal. All of this is going to be implemented in Redstone. Here you see an overhead diagram of the neural network in Minecraft. I've removed the top layers of the weights and the weight update mechanisms. Otherwise, you can see anything. The basic components of each of the weights are implemented in the multipliers you can see right here. Four weights, four multipliers. Each multiplier is followed by a division by four, which is this square thing right here. You can also clearly see the two hidden neurons here and here, where the non-linearity happens. And the two weights in the second layer are also implemented by these two multipliers. The output neuron is implemented at the back together with the output signal. For the back propagation, we have the two additional multipliers here and here to calculate the backprop signal to the first layer. On the bottom, you can see the timing signal to set the network into backprop mode. The first thing that happens is this first row of multipliers. There are four multipliers here. As you can see, there's one, there's two, there's three, and there's four. The four multipliers represent the four connections from the input layer to the hidden layer, since each of the two input neurons needs to be connected to each of the two hidden neurons. The connections have the multiplier to do the actual multiplication, and the weight of the connection is stored in a memory cell above, which you can see right here. This memory cell probably has a weight of about eight right now. Each memory cell is also accompanied by two pistons, one to add to it and one to subtract from it. Note that other than in the square root finder, here we don't just add and subtract one statically, but we actually compute the exact backprop signal that we need to add or subtract. Though I have implemented a limiting mechanism for the update, which you can set in these books right here. In this case, I've set it to two for this weight to not have it update too rapidly. You'll also notice that each of these update pistons is accompanied by another piston mechanism. This is for generating an ultra short pulse, which is necessary for us not to update too much, you'll be able to see the ultra short pulse in just a second. Watch the repeater as the piston moves up again. Did you see that ultra short pulse? I think it's known as a two tick or a three tick pulse, as a one tick pulse will actually have that piston expel its block and not retract it again. So after the first row of multipliers, each signal goes through a circuit like this where it is divided by four. This is done because again, we work in the range of zero to 15, which is not a whole lot. And we've already multiplied two numbers. So dividing the signal by four seems like a reasonable choice. After we divide the signal by four, it goes into the nonlinearity here conveniently labeled with a sign unlike almost everything else in the entire network. The nonlinearity is a ReLU nonlinearity, though it is not set at zero to cut off, it is set at four, we don't have negative signals in this game. So we'll have to work with what we get. One thing I implemented is that I do add one to whatever comes out of the nonlinearity to never have a zero signal and therefore never have a zero gradient for the later weights. Feel free to change that though, I have no clue if it works. Following the two nonlinearities, the second row of weights is coming. There's just two weights here since there's just one output neuron. There is one multiplier and there is one multiplier. Again, the weights are implemented by memory cells above with update mechanisms to add and subtract prepended by ultra short pulse generators. And again, you can adjust the learning rate using these lecterns. Once the output arrives, it is stored in this memory cell right here and this and displayed in the column of lights. Now that's where the interesting part only begins. The target value comes in through this current right here and is compared to the output value of the network. Here's where we calculate the error. We need to calculate it once into the positive direction and once into the negative direction. And we need to remember whether or not our signal was too high or too low. Two control lines signal for this. One goes underneath here, which is the negative line and one goes over top beer, which is the positive line. Once the error is calculated, the network switches into back prop mode. Back prop mode is controlled by a timer mechanism, which is composed of multiple stacked decaying memory cells. You'll see that this generates a really long pulse which controls for how long the network is in back prop mode. You can see it decaying very slowly. One cell after the other. Once all cells are decayed, the network is switched back into forward prop mode. Now what happens in this back prop mode? In back prop mode, two things happen. First of all, the network is configured to switch the multipliers here to instead of doing forward propagation, do back propagation. The back prop formula tells us that we have to multiply the error signal with the input signal to get the weight updates. Rather than implement separate multipliers for this multiplication, I decided to implement a routing mechanism that simply detects whether or not the network is in forward or in back prop mode and uses the appropriate inputs into the same multipliers. The result of the multipliers is then used as an update signal for the weights. In order to do back propagation through neural network, you also need to back propagate the error signal back to the first layer. For that, we need two extra multipliers, which I've implemented one here. This multiplier implements the back prop signal for the lower layer, including the gradient of the non-linearity and the division by four that we did in the forward propagation. It's important, but once we're done, this really gives us the exact back prop signal for the first layer. And again, we reuse the multipliers in the first layer and reroute the inputs to calculate the update signal during the back prop phase. Once back prop is done, a simple control signal instructs all the weights to update at once. You'll see it when this piston goes up. And the control signal instructs all the piston in the top layers to fire and update the weights. And that's it. That is one cycle through the network. Now, by mere accident, we have actually hit the correct output from the get-go, and thus nothing is updated. Let's try to overfit to one data point once more. So I've now switched the inputs to three and one. I'm going to set my target to 12. Let's see what happens and follow along once more. So I've now switched the inputs to 12 and one. Let's see what happens and follow along once more. The input goes through. The first row of multiplier hits. Signal travels backwards. The second row of multipliers hit. After that, the output is displayed. It is six right now still, but that's going to change. The network is switching into back prop mode, indicated by the flashing up there. You can see the multipliers in the first row hit. And now the weights are instructed to update. Up top. There we go. Good job. Once that's done, the control signal travels back and we go again. First row of multipliers travel back. Second row of multipliers. The output signal is stored in this memory cell and displayed right there. We're at nine. Network is flipped into back prop mode. These multipliers hit, including the multiplier for the back prop signal. First row of multipliers hit. And the weights are instructed to update. Weight update. There we go. Good job. Let's try that one more time. Forward prop first row. Forward prop second row. Output is saved and displayed. Beautiful. And that is an output of 12 for you. This was certainly a challenge. It started as an April Fool's joke and it turned out to be a lot of work, but also fun. And the live stream chat while I was building it was certainly super helpful and fun to watch. I kind of knew how to do the forward propagation once I had the multiplier figured out, but other than that, I had no idea what I was doing. So I will put these worlds on GitHub for you to mess around with and you can submit a pull request if you think you have a substantial improvement or maybe you'll even find a bug. It's quite probable, honestly. So in conclusion, we used a bunch of weird mechanics of Minecraft to build the first analog forward propagating, back propagating, weight updating, gradient dissenting, non-linearitizing, deep neural network in Minecraft. It was a pleasure. Thank you so much for watching and I'll see you next time. Bye bye.
 I built a fully functional, trainable, analog neural network in Minecraft with no command blocks and no mods.
 Check this out.
 Hello?
 Hello?
 Hi.
 Hi.
 I'm...
 I'm trying to build a neural net...
 Hi, I'm trying to build a neural network.
 Hi.
 Can you please...
 I don't want to buy your stuff.
 I'd like...
 No, I don't want a bucket of...
 No, I don't want a bucket of puffer fish.
 What you're seeing here is an analog neural network.
 While lots of people build binary computers in Minecraft, this neural network works in an analog fashion.
 It means it works directly with the signal strength on these wires right here.
 It has two layers, and it has two neurons in its hidden layer.
 It computes an output.
 It compares that output against the target.
 It back propagates the error back through the network.
 And it is even able to update its own weights in response.
 So it can fully autonomously learn any function that you want.
 So today I'm going to show you how I built this, how it works, and what could potentially be improved.
 Be sure to like this video, and let me know what you think in the comments.
 So the output is nine, and now I change the input back to the last data point.
 The max operation is actually released.
 Yes, but the org max isn't, right?
 It's six.
 He learned two data points.
 He learned two data points.
 He learned two data points.
 So this whole network runs on Redstone.
 Redstone is a concept in Minecraft that is a little bit like electricity.
 You can see right here the torch emits a signal, and it is transmitted across these wires in red right here.
 Now, the property of Redstone is that it starts out with a signal strength of 15,
 as you can see indicated by these lights.
 And for each distance that it travels, it drops by one signal strength.
 Now, most people simply use the on or off state of these wires as binary signals,
 and build computer out of that.
 However, I decided I wanted to use the signal strength directly as a signal,
 and build a neural network based on that.
 This gives us a much more compact neural network,
 and it is much more akin to how we build neural networks in machine learning,
 and also in the brain.
 Next, I'm going to show you the main components that we use to build this neural network.
 This here is a lector, and the building block right behind it is called a comparator.
 Now, the comparator has the ability to read signal from blocks before it.
 In this case, it reads the page of the book that is on the lector, here 9,
 and translates that into a Redstone signal.
 You can see the Redstone signal is 9 strong at the beginning,
 and decays with each distance traveled.
 Parators are actually a special block in Redstone,
 in that they can transmit a signal without it losing its strength over distance.
 In this demonstration, you can see the difference between a comparator
 and what is known as a repeater.
 The comparator simply transmits the signal one block and keeps its strength,
 while the repeater will fully power up the signal back up to 15,
 no matter what signal comes in.
 Only when a signal of 0 comes in is the repeater fully off.
 Another interesting fact about comparators is the fact that they can be used for doing math.
 In particular, they can do subtraction.
 Here we subtract the side signal from the main signal,
 which results in a resulting signal of strength 2.
 Note that this comparator is in subtraction mode, because its front light lights up.
 This neat thing right here is a divider.
 It divides the signal by 4, which is pretty cool.
 Since the Redstone signal is capped at 0 at the lower end and 15 at the higher end,
 we don't really have a lot to work with.
 Dividing by 4 is often useful to bring the signal back to a manageable range.
 So this would bring the signal from 0 to 15 to a range of 0 to 3,
 or 1 to 4, however we want it.
 The most important building block in a neural network is going to be what's known as a memory cell.
 This is a memory cell.
 It consists of two comparators, each feeding into a block,
 and each block powering a cable that then feds into the comparator again.
 This is a closed loop, and it will save any state that you give it.
 I can fully charge it with this button, and I can fully de-charge it with this button.
 A slight variation on the memory cell is the decaying memory cell, which I think is pretty cool.
 It is almost like a memory cell, but since this wire here is of length 2,
 it de-charges by 1 every time the signal goes around the cycle.
 So if I fully charge it, what you're going to see is that it slowly decays over time.
 Let me show that again.
 This is pretty cool.
 This is a multiplier.
 It is a device that can multiply two analog signals, and it is really cool how that works.
 It combines the memory cell and the decaying memory cell to achieve this multiplication.
 Again, the multiplication is in analog here, and not in binary.
 The design is from a YouTube channel called RKFValter,
 and I didn't come up with this myself, and it took me quite a while to understand what was going on.
 Though once I had it, I was able to build the rest of the neural network almost without a problem.
 At the bottom, you'll find a single memory cell that stores 15 minus whatever we want as an output.
 The signal is then fed into this comparator, which is in subtraction mode,
 and feeds from this hopper that is full.
 So the output is going to be here.
 On top of the memory cell, you'll find a decaying memory cell.
 The decaying memory cell powers this piston here,
 and it is fed via an ultra-short tick of this piston with this signal.
 This is one of our two input signals. As long as the decaying memory cell is active,
 this piston stays down. As long as this piston is down,
 our second input is fed through this circuit into the memory cell at the bottom and is subtracted.
 That means the bottom signal is subtracted from this memory cell
 an amount of times that is proportional to how long the piston stays down.
 This, as you can see, results in a multiplication of the two analog signals.
 Pretty cool. Here I use this to multiply the two numbers, two
 and three, as you can see by the pages of the book.
 As soon as I hit the button, the memory cell is reset, an ultra-short pulse is generated,
 and this piston stays down just long enough for the de-charge to happen an appropriate
 amount of times. You can see the result is six.
 And if I change this to a larger number, say five,
 you can see that the piston now stays down for much longer than before.
 Of course, we can only handle signals up to 15 even with this contraction.
 The last thing we need is gradient descent. By combining a multiplier and a memory cell
 together with two pistons that update the memory cell, we can achieve gradient descent.
 This here was my test application for gradient descent. It is a square root finder,
 and to my knowledge, it is also the first analog square root finder that is implemented in Minecraft
 Redstone. Innovation happening on this channel every day.
 So the way it works is that we have a memory cell that we can update using either this piston or
 this piston. We can update it up or down. We feed the signal from the memory cell as the
 first and the second multiplicand into the multiplier. The two numbers are then multiplied
 together and come out here. On this lectern, we set a target that we would like to know the square
 root of. In this case, I want to know the square root of the number nine. This circuit right here
 then calculates an error signal and tells the contraction down here whether we need to go up
 or down with our memory cell. Depending on that, either this piston or this piston is activated
 with an ultra short pulse, and we change the memory cell by one or negative one. If we repeat this
 cycle, eventually we should converge to the square root of whatever we input into this lectern.
 So if I hit the button right here, square is calculated, the error is calculated,
 the memory cell is updated, and you can see one is our first guess. Let's hit the button again
 and see what happens. We're at two. Now we're at three. If we hit the button again,
 we do expect the network to converge. So you can see there was no more update. So now we have
 converged on three, which is, of course, as you know, the square root of nine. If we input any
 other number than a pure square, the network is going to oscillate between the two square roots
 that are closest in integer. So here two, and now it oscillates back to three. Gradient descent
 in Minecraft. Thank you. The neural network is a bit more complicated in that it can not only do
 gradient descent by plus one or negative one, it will actually calculate the exact error signal
 that comes back from the front. It will calculate it through the nonlinearity, and it even has
 adjustable learning rates. All right, now let's try it out. So in this neural network, what you do is
 you use these two books to set the input signals for each of the two input dimensions. In this case,
 it's one and three. And you use this book to set the target value. In this case, I've set it to 12.
 That's a bit high. Let's set that to six. Once I hit this button, the whole operation starts
 in full automatic mode. Let's go. So what you're going to see is the signal forward traveling
 through the network, through the first layer, into the second layer, which you're going to see
 right now. After that, the output is going to be displayed after a short flicker on this pole right
 here. Now this happens to be exactly correct. It's not always the case. After this, the network flips
 into back prop mode, at which point the signal is traveling backward through the second layer to the
 first layer. At the end, this piston there is going to hit, which is going to implement the weight
 update given by these upper pistons right now. And after all of that, the control signal travels back
 and we start again. Let me show you a little bit more clearly what happens in each step.
 The neural network we're going to build here has two input neurons, which can be loaded with a value
 of anywhere between one to 15. This is followed by another layer of neurons. Two neurons form
 the hidden layer of the network and yet another layer, one neuron forms the output. Each layer is
 a fully connected layer, which means that every neuron in the layer before is connected to every
 neuron in the layer above. And the same goes for the second layer. Each of these layers has a weight
 associated with it. The back propagation formulas tell us how the signal flows forward in the
 network and also how the signal flows backward, while the optimizer formula is telling us how we
 need to update the weight once we have computed the back propagation signal. All of this is going to
 be implemented in Redstone. Here you see an overhead diagram of the neural network in Minecraft.
 I've removed the top layers of the weights and the weight update mechanisms. Otherwise, you can see
 anything. The basic components of each of the weights are implemented in the multipliers you
 can see right here. Four weights, four multipliers. Each multiplier is followed by a division by four,
 which is this square thing right here. You can also clearly see the two hidden neurons here and
 here, where the non-linearity happens. And the two weights in the second layer are also implemented
 by these two multipliers. The output neuron is implemented at the back together with the output
 signal. For the back propagation, we have the two additional multipliers here and here to calculate
 the backprop signal to the first layer. On the bottom, you can see the timing signal to set the
 network into backprop mode. The first thing that happens is this first row of multipliers. There
 are four multipliers here. As you can see, there's one, there's two, there's three, and there's four.
 The four multipliers represent the four connections from the input layer to the hidden layer,
 since each of the two input neurons needs to be connected to each of the two hidden neurons.
 The connections have the multiplier to do the actual multiplication, and the weight of the
 connection is stored in a memory cell above, which you can see right here. This memory cell
 probably has a weight of about eight right now. Each memory cell is also accompanied by two
 pistons, one to add to it and one to subtract from it. Note that other than in the square root
 finder, here we don't just add and subtract one statically, but we actually compute the
 exact backprop signal that we need to add or subtract. Though I have implemented a limiting
 mechanism for the update, which you can set in these books right here. In this case, I've set it
 to two for this weight to not have it update too rapidly. You'll also notice that each of these
 update pistons is accompanied by another piston mechanism. This is for generating an ultra short
 pulse, which is necessary for us not to update too much, you'll be able to see the ultra short
 pulse in just a second. Watch the repeater as the piston moves up again. Did you see that ultra
 short pulse? I think it's known as a two tick or a three tick pulse, as a one tick pulse will actually
 have that piston expel its block and not retract it again. So after the first row of multipliers,
 each signal goes through a circuit like this where it is divided by four. This is done because again,
 we work in the range of zero to 15, which is not a whole lot. And we've already multiplied two numbers.
 So dividing the signal by four seems like a reasonable choice. After we divide the signal
 by four, it goes into the nonlinearity here conveniently labeled with a sign unlike almost
 everything else in the entire network. The nonlinearity is a ReLU nonlinearity, though it
 is not set at zero to cut off, it is set at four, we don't have negative signals in this game. So
 we'll have to work with what we get. One thing I implemented is that I do add one to whatever comes
 out of the nonlinearity to never have a zero signal and therefore never have a zero gradient
 for the later weights. Feel free to change that though, I have no clue if it works.
 Following the two nonlinearities, the second row of weights is coming. There's just two weights here
 since there's just one output neuron. There is one multiplier and there is one multiplier. Again,
 the weights are implemented by memory cells above with update mechanisms to add and subtract
 prepended by ultra short pulse generators. And again, you can adjust the learning rate using
 these lecterns. Once the output arrives, it is stored in this memory cell right here and this
 and displayed in the column of lights. Now that's where the interesting part only begins.
 The target value comes in through this current right here and is compared to the output value
 of the network. Here's where we calculate the error. We need to calculate it once into the
 positive direction and once into the negative direction. And we need to remember whether or
 not our signal was too high or too low. Two control lines signal for this. One goes underneath here,
 which is the negative line and one goes over top beer, which is the positive line. Once the error
 is calculated, the network switches into back prop mode. Back prop mode is controlled by a
 timer mechanism, which is composed of multiple stacked decaying memory cells. You'll see that
 this generates a really long pulse which controls for how long the network is in back prop mode.
 You can see it decaying very slowly. One cell after the other. Once all cells are decayed,
 the network is switched back into forward prop mode. Now what happens in this back prop mode?
 In back prop mode, two things happen. First of all, the network is configured to switch the
 multipliers here to instead of doing forward propagation, do back propagation. The back prop
 formula tells us that we have to multiply the error signal with the input signal to get the weight
 updates. Rather than implement separate multipliers for this multiplication, I decided to implement a
 routing mechanism that simply detects whether or not the network is in forward or in back prop mode
 and uses the appropriate inputs into the same multipliers. The result of the multipliers is
 then used as an update signal for the weights. In order to do back propagation through neural
 network, you also need to back propagate the error signal back to the first layer. For that,
 we need two extra multipliers, which I've implemented one here. This multiplier implements
 the back prop signal for the lower layer, including the gradient of the non-linearity
 and the division by four that we did in the forward propagation. It's important,
 but once we're done, this really gives us the exact back prop signal for the first layer.
 And again, we reuse the multipliers in the first layer and reroute the inputs to calculate the
 update signal during the back prop phase. Once back prop is done, a simple control signal
 instructs all the weights to update at once. You'll see it when this piston goes up.
 And the control signal instructs all the piston in the top layers to fire and update the weights.
 And that's it. That is one cycle through the network. Now, by mere accident, we have actually
 hit the correct output from the get-go, and thus nothing is updated. Let's try to overfit to one
 data point once more. So I've now switched the inputs to three and one. I'm going to set my
 target to 12. Let's see what happens and follow along once more. So I've now switched the inputs
 to 12 and one. Let's see what happens and follow along once more. The input goes through. The first
 row of multiplier hits. Signal travels backwards. The second row of multipliers hit. After that,
 the output is displayed. It is six right now still, but that's going to change. The network
 is switching into back prop mode, indicated by the flashing up there. You can see the multipliers in
 the first row hit. And now the weights are instructed to update. Up top. There we go.
 Good job. Once that's done, the control signal travels back and we go again. First row of
 multipliers travel back. Second row of multipliers. The output signal is stored in this memory cell
 and displayed right there. We're at nine. Network is flipped into back prop mode.
 These multipliers hit, including the multiplier for the back prop signal.
 First row of multipliers hit. And the weights are instructed to update. Weight update.
 There we go. Good job. Let's try that one more time. Forward prop first row.
 Forward prop second row. Output is saved and displayed.
 Beautiful. And that is an output of 12 for you. This was certainly a challenge. It started as an
 April Fool's joke and it turned out to be a lot of work, but also fun. And the live stream chat
 while I was building it was certainly super helpful and fun to watch.
 I kind of knew how to do the forward propagation once I had the multiplier figured out,
 but other than that, I had no idea what I was doing. So I will put these worlds on GitHub for
 you to mess around with and you can submit a pull request if you think you have a substantial
 improvement or maybe you'll even find a bug. It's quite probable, honestly. So in conclusion,
 we used a bunch of weird mechanics of Minecraft to build the first analog forward propagating,
 back propagating, weight updating, gradient dissenting, non-linearitizing,
 deep neural network in Minecraft. It was a pleasure. Thank you so much for watching
 and I'll see you next time. Bye bye.