Quantcast
Viewing all articles
Browse latest Browse all 148

Train your very own AI

Training artificial intelligence (AI) can be as easy as 1, 2, 3! Teach an AI program or “model” to pull off a very simple card trick… and learn from its mistakes. 

Image may be NSFW.
Clik here to view.
Playing cards falling in a clump with a black background.

Credit: GettyImages/Sunny

You will need

  • Computer connected to the internet
  • Browser (like Chrome or Firefox)
  • This zip file of playing card images

Safety

This activity requires using the internet, downloading a zip file and uploading files to a web-based application. Ask an adult to supervise these steps. If you ever feel unsafe on the internet, let an adult know.

Image may be NSFW.
Clik here to view.

What to do

  1. Download this folder of playing card images. Double click to unzip the file and open it in its own window so you can see a list of all the card files. You’ll be dragging and dropping files from this folder to your AI model.

    Image may be NSFW.
    Clik here to view.
    Image of computer screen with list of file names.
  2. Open a browser window and go to Teachable Machine with this link: https://teachablemachine.withgoogle.com/.

    Image may be NSFW.
    Clik here to view.
  3. Click the big blue “Get Started” button, choose “Image Project” from the resulting options.

    Image may be NSFW.
    Clik here to view.
  4. Choose “Standard Image Model” from the pop-up window. Now you’re ready to start teaching your AI model!

    Image may be NSFW.
    Clik here to view.
  5. Click the pencil next to “Class 1” and rename it to “Red”. Do the same to rename “Class 2” to “Black”.

    Image may be NSFW.
    Clik here to view.
  6. Under “Red”, click the “Upload” button.

    Image may be NSFW.
    Clik here to view.
  7. In the folder window of your playing card files, search for “diamonds” so only those files show up.

    Image may be NSFW.
    Clik here to view.
  8. Drag and drop all the files from “2_of_diamonds.png” through to “8_of_diamonds.png” into the blue file area under “Red”. Pictures of these seven cards should appear under the words “Add Image Samples”. You’ve just labelled your Red data!

    Image may be NSFW.
    Clik here to view.
  9. Now for Black! Under “Black”, click the “Upload” button. Search for “spades” among your playing cards. Next, drag and drop all the files from “2_of_spades.png” through to “8_of_spades.png” into the blue area under “Black”. Pictures of these seven cards should appear to the right.

    Image may be NSFW.
    Clik here to view.
  10. Time for your AI model to learn! Hit the “Train model” button.

    Image may be NSFW.
    Clik here to view.
  11. Now, let’s see how it does with cards it’s never seen before. On the “Preview” panel, click the “Webcam” button and switch it to “File”.

    Image may be NSFW.
    Clik here to view.
  12. Find the “9_of_spades.png” file and drag it into the blue box with the folder icon. Look below the image to the “Output” window. Did your AI get the suit colour right?

    Image may be NSFW.
    Clik here to view.
  13. Let’s keep testing your AI model with cards it hasn’t seen before. How does it do with the ace of spades? The 10 of diamonds? What about a card from the clubs or hearts suits? Here’s a big test: how does it do with the fancy face cards like “king_of_spades2.png”?

  14. Can you improve your model or make a new one that can tell face cards apart?

  15. Teachable Machine takes in lots of different types of data! If you’re keen, try a webcam, audio or pose project. You can make a new project by clicking on the blue “Teachable Machine” button in the top left corner and choosing “New Project”.

    Image may be NSFW.
    Clik here to view.

What’s happening?

You get smarter by learning and so do machines! You learn by taking in information from books, friends, school and more. Often, you’re looking for patterns and making connections between old and new information. Nowadays, machines can do this, too! But they need to learn from lots of examples. Computer scientists call these examples “data”.  

Data can be numbers, text, images and even video. These files give the computer the raw information it needs to look for patterns. But before it can find patterns, your AI model needs your help. That’s why you started by labelling some data as either red or black. You’re acting like a teacher! Computer scientists call this style of machine learning “supervised learning”.

The next step is training. Flash cards can help you learn a new topic, right? Well, your AI model uses labelled data a bit like flash cards to find patterns, test these patterns and improve. You can play with this process in the Advanced settings under the “Train Model” button. Try increasing the “Epochs” number to 1,000. This tells the AI model to practise with your training data 1,000 times. Did your better-practised AI get the face cards right?

AI and human error

When trained on a few diamonds and spades cards, your model could correctly identify hearts and clubs as red and black – that’s a neat trick!

But, your AI model is only as good as the data you give it. This model often fails on some face cards. Why? For starters, face cards have pictures that are both red and black. None of the training cards looked like that. By excluding face cards, our AI never learned that these cards have special patterns.

Training AI models on high quality data is a real challenge for computer scientists. Even a big set of data can be missing key information.

Even worse, data can pass on human biases or prejudices. For example, according to Wired, when asked to draw some doctors in 2022, the generative AI “Dall-E Mini” only drew men. So, it’s very important for computer scientists to collect training data carefully, to check for biases and adjust the data to fix these biases.

Now that you’ve trained your own AI, you have a much better sense of how machines learn, and you can keep an eye out for possible biases in AIs, too.

The post Train your very own AI appeared first on Double Helix.


Viewing all articles
Browse latest Browse all 148

Trending Articles