Say “Hello world!” in AI

Hello World  program is usually the first program written by people learning to code.

This is how Hello World looks like in C:

#include <stdio.h>
int main()
   // printf() displays the string inside quotation
   printf("Hello, World!");
   return 0;

This is how Hello World looks like in Python:

print("Hello, World!")

And this is how it looks in Brainfuck:


But how does a Hello World program looks like in AI? That’s a tricky question, because AI is not regular programming, where you express rules in code, in fact AI is all about making computers infer those rules for you based on data.

In traditional programming your code compiles into a binary that is typically called a program. In machine learning, the item you create from the data and answers is called a model.

Formalising the Hello World for AI

Given input data (training data) & answers (target variable or labels) find the rules (model or approximate function) for:


 Can you see the relationship between X and y?

YOU know that in the function, the relationship between the numbers is y = 2x + 1. But how does the machine does it? 

By running labeled training data through a learning algorithm, so that the learned function predicts y as accurately as possible.

import tensorflow as tf
import numpy as np
from tensorflow import keras

model = tf.keras.Sequential([keras.layers.Dense(units=1, input_shape=[1])])
model.compile(optimizer='sgd', loss='mean_squared_error')

X = np.array([-1, 0, 1, 2, 3, 4]).reshape(-1,1) # two-dimensional array
y = np.array([-1, 1, 3, 5, 7, 9]), y, epochs=500)


Leave a Reply

Your email address will not be published. Required fields are marked *