We deliver to Europe! | E-Mail: info@omtec.de | Contact form

Part 5, January 13, 2021 - Become an AI programmer in 15 minutes

Tell your friends, after studying AI for just 15 minutes, that you are an AI programmer from now. You don't need any previous programming experience, but a Google account.

The minimal working example, presented by AI enthusiasts Jacob Beautemps and Philip Häussler here, is: “Find out, how the number series y = [2,4,6] depends on x = [1,2,3], and make a forecast for x = 7.” This example strikingly shows all you need to know about AI.

Don’t worry, if you don’t understand any German. All relevant explanations are given as English comments in the table below.

Follow the link to the Google Colab project (also given in the video description). Then, execute the example AI program by pressing the “Play” button (inside the square brackets in front of “import”) and wait for the result. At next, to become a real programmer, you may, for example, change the number of "epochs". It fixes, how often your AI has the chance to learn and to improve the result. Finally, restart your AI.

You ‘ll learn quite a lot about AI in the next quarter of an hour. We only want to anticipate one of those insights here: your human intelligence immediately has recognized the dependency of y on x, however, the AI needs “understanding” the same some seconds. This shows, for real application, that AI performance relies on very high computing power ... that is, on hardware that you can find at Omtec.

 

CommandComment
import tensorflow as tf Here we import the tensorflow library, which is the perfect introduction to neural networks. A library is a prescribed program. It makes our work a lot easier.
from tensorflow import keras We import a special part from tensorflow: keras.
model = keras.Sequential ([keras.layers.Dense (units = 1, input_shape = [1])]) We define our neuronal network, and create a neuron as Dense. There is only one neuron in this example, usually AI works with significantly more neurons. Our neuron is in one layer, and more neurons entail several layers. Think of them like levels in a mesh.
model.compile (optimizer = 'sgd', loss = 'mean_squared_error') Here we compile our neural network, whereby loss measures the degree of error, which is then optimized with optimizer.
xs = [1, 2, 3] Series of numbers 1
ys = [2, 4, 6] Series of numbers 2
model.fit (xs, ys, epochs = 1000) We fit our compiled model with our two series of numbers. epochs = 1000 means that the program makes 1000 runs in order to train. Feel free to change the number. The more runs, the better the estimate. At the same time, you can see that the change in loss becomes less and less, the more runs are made. So, at some point, there is hardly any improvement.
print (model.predict ([7])) Here we let our neural network estimate the second number (new ys) if the first number is 7 (new xs). The print command simply displays the output value.
Tags: KI

The fields marked with * are required.

Die Datenschutzbestimmungen habe ich zur Kenntnis genommen.