2018年6月4日月曜日

Consturuct a neural network (multilayer perceptrons) using micro:bit

notice:
This article treats only forward propagation, whereas, backward propagation is also demonstrated in another article. -> Please see here.

Let's learn the basics of neural networks using micro:bit. Understanding deepens by actually programming. For neural network learning to solve various tasks, back propagation is generally required. Learning with this back propagation requires considerably long time calculations. It is not realistic to do this with such a tiny microbit with low computing power, even though it is not impossible. Therefore, here we will try forward calculation only, using the edge weights of the already learned neural network. Even so, you can experience some of the important points of the neural network.

Neural network with micro:bit

 this illustrates evaluation of z = XOR(1,1) = 0

One thing to notice here is that one microbit plays a role of one neuron. By doing so, you can have an image that is close to real neurons. Here, XOR (Exclusive OR) is the problem. z = XOR (x, y) shows 1 only if either x or y is exclusively 1. Otherwise the value of z is 0. In the microbit, JavaScript and MicroPython can be used, but here we use MicroPython. The reason is that microbit JavaScript currently does not support calculation of float type data. Float type operation is mandatory for calculation of Neural network. Also, neurons (microbit) exchange signals with each other. For that we use send / receive on radio. This is not Bluetooth. Additionally, as the activation function, we use the sigmoid function.

The weights of the edge used above are the results of being learned by the following NetLogo program that is based on the following one:
The red line denotes a negative value, the blue line denotes a positive value, and the thickness shows the magnitude of the absolute value.

Weights used in the above example were obtained by this NetLogo  simulation

Please see the video for an actual operation example.
https://youtu.be/PPUcsXgCnZ4

In the first half, z = XOR (x, y) is calculated where x = 1, y = 1, and then the value 0.0178... was obtained, so that "0" was finally displayed. On the other hand, the second half is the case of x = 1 and y = 0. Now that 0.9852... has been obtained, "1" was displayed as the final result of z.


0 件のコメント:

コメントを投稿