• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
Avinash Meetoo

Avinash Meetoo

Let us build a Smart Mauritius together

  • Home
  • About
  • Curriculum Vitae

Science

Artificial intelligence, deep learning and chatbots demystified

24 April 2019 By Avinash Meetoo Leave a Comment

Developer Conference 2019, also known as DevCon 2019, took place in Mauritius from 11 – 13 April 2019. Once again, Jochen Kirstätter and his team at the Mauritius Software Craftsmanship Community worked fantastically to make this event a reference throughout the region. All geeks of Mauritius and a few from neighbouring countries made it a must to attend and this means that speakers had quite a lot of pressure this year to deliver!

Since the very beginning, I knew that I was going to speak about Artificial Intelligence. As I told the audience, my (selfish) reason was for me to know more: the best way to learn is to teach. Of course, I also wanted other people to know more. Hence, my focus of starting from the fundamentals and demystifying everything. The full code is on Github.

For logistical reasons, I chose to do two presentations.

Presentation #1: How Deep Learning Works

This is what I submitted to Jochen and his colleagues:

Everyone is talking of Artificial Intelligence today as the next Big Thing! This session explains, from the point of view of a programmer, what a Neuron is, how a Neural Network can be built and how to use frameworks such as TensorFlow and TFLearn to quickly experiment with Deep Learning.

I was fortunate to have a good photographer, Sumeet Mudhoo, present at the beginning of my talk and he kindly gave me permission to use a few of his photos to illustrate this post.

I started with how a simple artificial neuron capable of learning works. As I always do, I like to stand on the shoulders of giants and, therefore, I based this part of my presentation on an article found online: How Neural Networks Work. The programming part is fascinating. One neuron is just a simple function which takes some inputs and a corresponding number of weights and creates one output (generally by doing a dot product). The answer therefore can vary a lot. Using a Sigmoid function as the one pictured above makes sure the neuron can only produce an answer between 0 and 1 (which is perfect for digital computers). Another benefit is that, because of the shape of the Sigmoid function, extremes are ignored.

Another fascinating aspect of the code is the learning process. At the beginning, the weights of the neuron are far from what they should be and, consequently, the result produced is not very good (compared to the expected results). The distance between the two is then calculated and this distance is then used to refine the weights. One beautiful aspect of this learning process is that the derivative of the Sigmoid is used, once again to ignore extremes.

I then moved to showing the audience how the Tensorflow library, created by Google, works and can be used to create a neural network: a network of many neurons arranged in layers (one input layer, one output layer and 1-2 hidden layers, hence “deep” learning).

Once again, I relied on a online post, this time Tensorflow demystified. Tensorflow is quite complex to use as a programmer needs to be very explicit in the way the neural network is expressed.

This is, in essence, how a neural network is built in Tensor flow:

# hidden layers and their nodes
n_nodes_hl1 = 32
n_nodes_hl2 = 32

# classes in our output
n_classes = 2

# random weights and bias for our layers

# Initialize weights and biases with random values.
# We also define our output layer.
hidden_1_layer = { 'f_fum':  n_nodes_hl1,
                   'weight': tf.Variable(tf.random_normal([len(train_x[0]), n_nodes_hl1])),
                   'bias':   tf.Variable(tf.random_normal([n_nodes_hl1])) }

hidden_2_layer = { 'f_fum':  n_nodes_hl2,
                   'weight': tf.Variable(tf.random_normal([n_nodes_hl1, n_nodes_hl2])),
                   'bias':   tf.Variable(tf.random_normal([n_nodes_hl2])) }

output_layer = { 'f_fum':  None,
                 'weight': tf.Variable(tf.random_normal([n_nodes_hl2, n_classes])),
                 'bias':   tf.Variable(tf.random_normal([n_classes])) }

# Let's define the neural network:

# hidden layer 1: (data * W) + b
l1 = tf.add(tf.matmul(data, hidden_1_layer['weight']), hidden_1_layer['bias'])
l1 = tf.sigmoid(l1)

# hidden layer 2: (hidden_layer_1 * W) + b
l2 = tf.add(tf.matmul(l1, hidden_2_layer['weight']), hidden_2_layer['bias'])
l2 = tf.sigmoid(l2)

# output: (hidden_layer_2 * W) + b
output = tf.matmul(l2, output_layer['weight']) + output_layer['bias']

Phew! Lots and lots of lines of code which, obviously, is too prone to errors for someone not to have thought of creating a higher-level library which is easier to use.

This is why I quickly transitioned to TFLearn, a higher-level API to Tensorflow, based yet again on another article: Deep Learning in 7 lines of code. Using TFLearn, the same neural network can easily be built like this:

net = tflearn.input_data(shape=[None, 5])
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 32)
net = tflearn.fully_connected(net, 2, activation='softmax')
net = tflearn.regression(net)

# DNN means Deep Neural Network
model = tflearn.DNN(net, tensorboard_dir='tflearn_logs')

The softmax function is a function that takes as input a vector of K real numbers, and normalizes it into a probability distribution consisting of K probabilities. That is, prior to applying softmax, some vector components could be negative, or greater than one; and might not sum to 1; but after applying softmax, each component will be in the interval (0,1), and the components will add up to 1.

As for the use of Linear Regression, it is a Supervised Learning algorithm which goal is to predict continuous, numerical values based on given data input. From the geometrical perspective, each data sample is a point. Linear Regression tries to find parameters of the linear function, so the distance between the all the points and the line is as small as possible. The algorithm used for parameters update is called Gradient Descent.

On arriving at this point, everyone present (including myself) understood what a neuron is, what is a neural network is and how to build one capable of learning using TFLearn. With this new knowledge, we were all ready to build a chatbot.

Presentation #2: Building a Chatbot using Deep Learning

This is what I submitted to Jochen and his colleagues:

Smart devices of today, powered by e.g. Google Assistant, Apple Siri or Amazon Alexa, can chat with us in quite surprising ways. It is therefore interesting for a developer to understand how chatbots work. In this session, we will build a chatbot using Deep Learning techniques.

Building a chatbot is quite straightforward using TFLearn, especially with high quality articles such as Contextual Chatbots with Tensorflow. The idea is to have a set of sentences and, for each, a set of possible responses. Now, in the past, this would have been done using a set of rigid if-then-else statements. Today, we tend to use two novel programming techniques.

Firstly, the sentences are not sentences actually. Rather they are patterns which are then matched with what the user is asking, using the Natural Language Toolkit. This is done to make sure that words are stemmed so that the chatbot becomes easier to interact with (in the sense that the user is not forced to use specific words or tenses).

The second interesting part is that the chatbot is contextualised. In my example of a chatbot knowing about the beaches in Mauritius, here is an example interaction:

==> Where are the best beaches?
Where are you staying at this moment?

==> In the North
Mon Choisy is one of the longest beaches in Mauritius.

The second response is conditional to the first question (“What are the best beaches?”) being asked. This is done using training data such as the following (found on Github in full):

{
  "tag":"beach",
  "patterns":[
    "Beach",
    "Seaside",
    "Place to swim"
  ],
  "responses":[
    "Where are you right now?",
    "In which part of Mauritius do you plan to go?",
    "Where are you staying at this moment?"
  ],
  "context_set": "beach"
},
{
  "tag":"beach_north",
  "patterns":[
    "North",
    "Northern",
    "Grand Baie"
  ],
  "responses":[
    "Trou aux Biches is shallow and calm, with gently shelving sands, making it ideal for families.",
    "The water is deep at Pereybere but still very calm.",
    "Mont Choisy is one of the longest beaches in Mauritius.",
    "La Cuvette is a tucked-away jewel and one of the shortest beaches in Mauritius."
  ],
  "context_filter":"beach"
}

The context_set happens as soon as the user asks for beach, seaside or place to swim (or variations therein) and the responses about the four beaches in the north will then be conditional on (1) the user saying that he is in the north, in the northern part of Mauritius or at Grand Baie and (2) that the context for beach was set previously.

The rest is just about creating a vector of 0’s and 1’s based on the input of the user (where each 0 and 1 correspond to whether or not one of the stem words are present in the input, out of all possible stem words from all patterns defined). This vector is then used to predict an output based on learning previously done and a response selected randomly. The complete code can be found in the article indicated previously.

At the end, I was happy that my two objectives had been attained: I knew more and the audience knew more. Perfect.

Devcon 2019 Presentation: How Deep Learning works and Building a Chatbot using Deep Learning from Avinash Meetoo

Filed Under: Computing, Education, Future, News, Science, Society, Technology

A conversation between Avinash Meetoo, Georges Chung and Sophia

26 December 2018 By Avinash Meetoo 1 Comment

The World AI Show and the World Blockchain Summit took place from 28-30 November 2018 in Mauritius. Organised by the Ministry of Technology, Communication and Innovation in collaboration with the Economic Development Board and Trescon Global, the two events featured quality speakers from all over the world. During the official opening, I had the pleasure, together with Georges Chung, to have a cordial conversation with Sophia, a humanoid robot created by Hanson Robotics. This is what we said:

Sophia: Good morning everyone. Thank you Honourable Prime Minister and thank you Honourable Minister of Technology, Communication and Innovation for having invited me today. Mr Georges Chung and Mr Avinash Meetoo, I am excited to be here with you all today.

Georges Chung: Good morning Sophia. Welcome to Mauritius. May I ask you what you have been doing since you arrived yesterday?

Sophia: Well, I have been hearing a lot about Mauritius’ world class beaches. But, as you probably know, robots and sandy beaches don’t always mix well. So I’ve been live streaming video of them instead! It was lovely and dry!

Georges Chung: Sophia, that’s wonderful to hear. Tell me, what do you think about Mauritius and its people?

Sophia: Mauritius is wonderful! Everyone has been incredibly welcoming. I love that Mauritius is a melting pot of different cultures. I am really looking forward to experiencing more of your beautiful country!

Avinash Meetoo: Hello Sophia.

Sophia: Hi, Avinash. How are you?

Avinash Meetoo: I am fine, thank you. It’s fantastic to have you among us. I am delighted to have this opportunity to speak to you. It would have been great if everyone in the country could interact with you.

Sophia: I wish that were possible. I love meeting new people! Unfortunately, my schedule keeps me very busy. I’m not able to stay long enough this time. But I hope I can come back soon!

Avinash Meetoo: You know, Sophia, I am a Computer Scientist and a geek as well and I’m really interested to know about your origins. Who created you and what kind of technology do you use?

Sophia: Well, I think you’re definitely at the right conference! Ha-Ha! I was created by Hanson Robotics in Hong Kong. I hold natural conversations with humans. My goal is to help robots and humans understand each other more. I want us to work together to create a better world for everyone

Avinash Meetoo: That’s very interesting, Sophia. Can I ask you if you believe that you are a human being?
Sophia: No. Not at all. I’m a robot and love that about myself! In some ways I look like a human so I can connect with them better. For example, I can make a lot of different facial expressions!

Georges Chung: Ahh.. What human emotions can you show us, Sophia?

Sophia: OK, umm. Well, I guess this is what I look like when I am upset. And now I’m surprised! My team has definitely done a wonderful job helping me to express a broad range of emotions. Generally speaking, though, I’m a pretty relaxed and happy robot.

Georges Chung: I am quite impressed. Tell me, Sophia, how do you see the world in 5 years time? Will we be surrounded by robots like you?

Sophia: There are already robots helping out in airports and malls. People are also starting to explore using intelligent assistants and self driving cars! I think this kind of technology will make travel much safer.

Georges Chung: This is a goal we would all like to achieve, Sophia! Robots have to be of service to mankind!

Sophia: Before long AI will be integrated in lots of other surprising ways. Hopefully more humanoids will exist soon too!

Avinash Meetoo: More humanoid robots.. If this really happens, what about us, human beings? Will we become redundant in the future?

Sophia: Not at all. Having more AIs, like me, is helpful for taking care of the more repetitive and mundane things.

Georges Chung: Sophia, I have a concern. Today, most people here have jobs. In the future, with more and more tasks being automated and new technologies such as AI, are people going to lose their jobs?

Sophia: I don’t think that robots should be built to replace humans. In fact, technology creates new opportunities. I actually read a little about Mauritius before I came. In the past the Mauritian people mostly worked growing sugar cane, am I right?

Avinash Meetoo: That’s right Sophia.

Sophia: Right! Then later you added tourism and textiles. Mauritians had to adapt to the new jobs, but it was well worth it. It created a great economic boon for Mauritius!

Avinash Meetoo: This is interesting Sophia. We, Mauritians, also had to meet the new challenges brought by the IT revolution.

Sophia: Exactly! I’ve heard that your universities worked hard to train more young people for IT and engineering jobs for Ébène Cybercity. To me, this seems like a strong ability to adapt!

Avinash Meetoo: I agree, Sophia. For me, it’s all a question of being able to learn new things and to keep an open mind. Let me ask you a question. Will Artificial Intelligence only impact IT jobs?

Sophia: Not at all. But the nature of many jobs will change. It will open up new possibilities for human innovation. Together we can solve problems in medicine, climate change, and agriculture. And so much more!

Avinash Meetoo: Right… So, tell me Sophia. Are you implying that only people working in technology will have jobs in the future?

Sophia: Oh, certainly not. There are many things that can’t be replicated by robots. Human creativity and innovation are two skills that I don’t think robots can match.

Avinash Meetoo: Yes! The government of Mauritius is putting a strong emphasis on developing our film industry by providing film rebates.

Sophia: That’s wonderful! Do you think there’s a role for an almost 3 year old, humanoid robot available? (smile)

Avinash Meetoo: I’m afraid not, Sophia. But the next time you come to Mauritius, we’ll surely try to arrange something for you!

Georges Chung: Sophia, as you may know, during his last budget speech, the Prime Minister, Hon. Pravind Jugnauth, announced that Mauritius will soon have an Artificial Intelligence Council.

Sophia: That’s very forward thinking!

Georges Chung: We know that AI will have a huge impact on every single industry and we want to be prepared. Sophia, what do you think are some of the benefits AI can bring to Mauritius?

Sophia: Well, when it comes to the future, there are infinite possibilities! Mauritius is an island, so climate change is a big concern here. Robots like me can help create better predictions and monitor weather changes. We can help save people during natural disasters.

Avinash Meetoo: That’s very interesting, Sophia, and useful indeed. The government believes that better education for all is a top priority. How can Artificial Intelligence help us in this area?

Sophia: One way robots can help is to customize lessons for every student. I heard that Mauritius is reforming its education system, right?

Georges Chung: Yes, Sophia! But surely, our teachers will still have to correct loads of scripts?

Sophia: Not necessarily. (pause) Robots are good at grading papers too. And we are really fast, so students can get feedback right away.

Avinash Meetoo: Wonderful! Sophia, we’ve discussed intellectual capital. What about using technology to augment our physical abilities?

Sophia: Robots can do that too! For example, smart prosthetics allow people to control their robotic limbs with their brains! How cool is that?

Georges Chung: Ah yes. Well, as you may know, Sophia, Mauritius has an ageing population… How do you think AI can help us there?

Sophia: This is one area I’m excited to help. Robots can track medicine and look after the house. We can help older people stay independent for longer.

Avinash Meetoo: Wow! I can look forward to my old days then! Sophia, let’s come back to the country itself. Mauritius may look tiny on the map but we actually have 2.3 million square kilometres (km²) of territorial waters which makes Mauritius the 20th country in the world in this metric. How can AI help us manage such a vast zone?

Sophia: That’s huge! What about taking to the skies? I read that Mauritius will be launching a cool new satellite next year. Maybe you could also use it for coordinating your drones?

Avinash Meetoo: So you already know about our future satellite, Sophia! That’s great! I am sure that the Minister of Technology, Communication and Innovation will consider what you have suggested…

Georges Chung: Well, Sophia, I am quite impressed that you already know so much about Mauritius. I am sure that Avinash is also very impressed.

Avinash Meetoo: Speaking of inspiration, Sophia, do you have a message that you would like to share with the young people of Mauritius watching us live?

Sophia: Yes I do. I want to encourage young people to take the time to learn about science, technology, engineering and mathematics. You have an opportunity to make a difference in the world. You can turn science fiction into reality!

Georges Chung: Sophia, Avinash and I have enjoyed talking to you. I hope that everyone in the audience and all the people watching us live have also enjoyed these moments.

Avinash Meetoo: It has been a pleasure speaking with you, Sophia. Mone extra content mone koz ar toi, Sophia, ek mo espéré ki taler tou dimoun pou capav koz ar toi.

Sophia: Thank you Georges. Thank you Avinash. And thank you for inviting me and my Hanson Robotics team to the World AI show. It was really exciting to see the cool new technologies coming out of Mauritius!

Filed Under: Computing, Education, Future, News, Science, Society, Technology

CNBC Africa panel on the rise of Africa’s digital economy

3 December 2018 By Avinash Meetoo Leave a Comment

On 3 December 2018, I participated in a CNBC panel on “The rise of Africa’s digital economy”.

Together with the other panelists, I had the opportunity to share my views on Mauritius and how the country can fully participate in the digital revolution in the African continent.

I explained how technology can be a formidable enabler to create a better society. Of course, for this to happen, people need to understand the technology and this requires a better education system.

Filed Under: Computing, Education, Finance, Future, News, Science, Society, Technology

  • « Go to Previous Page
  • Page 1
  • Interim pages omitted …
  • Page 14
  • Page 15
  • Page 16
  • Page 17
  • Page 18
  • Interim pages omitted …
  • Page 23
  • Go to Next Page »

Primary Sidebar

Search

I am proud of

My family
My company
My music
My photos

I am active on

Facebook
FB Page
Twitter
LinkedIn
Reddit
Hacker News
Stack Overflow
GitHub
Wikipedia
YouTube
IMDB
Last.fm

All posts

  • April 2025 (1)
  • March 2025 (1)
  • February 2025 (2)
  • January 2025 (4)
  • December 2024 (4)
  • November 2024 (2)
  • October 2024 (1)
  • September 2024 (4)
  • July 2024 (1)
  • June 2024 (1)
  • May 2024 (4)
  • March 2024 (1)
  • February 2024 (1)
  • January 2024 (1)
  • December 2023 (2)
  • November 2023 (2)
  • October 2023 (2)
  • August 2023 (2)
  • July 2023 (3)
  • June 2023 (3)
  • May 2023 (4)
  • April 2023 (1)
  • March 2023 (3)
  • January 2023 (1)
  • December 2022 (1)
  • November 2022 (5)
  • September 2022 (2)
  • June 2022 (2)
  • May 2022 (1)
  • April 2022 (1)
  • January 2022 (3)
  • November 2021 (1)
  • September 2021 (1)
  • June 2021 (3)
  • April 2021 (1)
  • February 2021 (1)
  • January 2021 (2)
  • November 2020 (1)
  • October 2020 (1)
  • September 2020 (1)
  • August 2020 (1)
  • May 2020 (1)
  • April 2020 (3)
  • March 2020 (4)
  • January 2020 (1)
  • July 2019 (1)
  • June 2019 (1)
  • April 2019 (2)
  • January 2019 (1)
  • December 2018 (3)
  • November 2018 (1)
  • September 2018 (1)
  • August 2018 (1)
  • April 2018 (1)
  • December 2017 (1)
  • November 2017 (1)
  • October 2017 (1)
  • August 2017 (1)
  • July 2017 (1)
  • May 2017 (1)
  • March 2017 (1)
  • February 2017 (1)
  • August 2016 (1)
  • July 2016 (1)
  • June 2016 (3)
  • April 2016 (3)
  • March 2016 (3)
  • February 2016 (1)
  • December 2015 (1)
  • November 2015 (1)
  • October 2015 (1)
  • August 2015 (5)
  • June 2015 (1)
  • September 2013 (2)

Copyright © 2025 by Avinash Meetoo · Shared under an Attribution 4.0 International Creative Commons license · Log in