Unit 5: Neural Network 1

Objective

In this unit we will introduce the basic concept of neural network.  Neural network is one of the most important invention in the development of AI.

We will talk about input neurons, output neurons, and the connections. We will conduct an activity which will help to illustrate these components and the basic operation of neural network. We also examines how weights are adjusted (changed) to achieve learning.  Actual calculation is not required in this unit.

Teaching (Neural Network)

What is Neural Network?

  • Also called Artificial Neural Network (ANN)
  • Inspired by the biological neural network that constitute human brains
  • An ANN is a collection of connected artificial neurons.
  • There is an input layer containing input neurons.
  • There is an output layer containing output neurons.
  • Each connection can transmit a signal from one neuron to another neuron.
  • Each connection have a weight that will be adjusted automatically by the algorithm (neural network) as learning happens

A simple example of neural network.

can you find the input neurons?

Can you find the output neurons?

Can you find the connections?

Actual application of neural network in the AlphAI:

Activity - Red Light, Green Light

Objective:

- have the weights changed after training?

Material:

2 input cards (about 10 cm x 10 cm) which indicate Green and Red with large rectangle.

Setup:

(1) the robot is put on top of small solid blocks which can allow the wheels running freely in the air without moving.

(2) the robot (the camera) is put 4 to 5 cm in front of a stand (or a wall).

AI Parameters

See appendix A1

Activity - train the robot to detect red and green

Switch on and connect the robot to your PC.  Press the <Connection> button.

With the the AI parameters set up correctly, the following neural network will be shown.

Note that:

- input neurons are marked with blue rectangles.  There are 2.

- output neurons are marked with green rectangles.  There are 2.

- there are 4 connections.

- 4 weights are circled in red.

Below is an enlarged picture for the input values and the weight values.  The values are extracted for easy reference.  Note that 2 weights are negative numbers.

Label the Output: Green Card - Go Forward; Red Card - Stop!

Training

(A) Values of the weights before training

- click the <reset learning> button once

- copy values of the 4 weights into the following diagram.

 

- click the <learning> button

- put the "Red" card on the stand.  Look at the camera on the computer screen.  If it is detected correctly, click 5 times the output according to the labeled chart (STOP!).

- put the "Green" card on top of the "Red" card (or on the stand).  Look at the camera on the computer screen.  If it is detected correctly, click 5 times the output according to the labeled chart (Go Forward).

- Remove the "Green" card and leave the "Red" card on the stand.  Click 5 times the output according to the labeled chart (STOP!).

(B) Values of the weights after training

- Off the <learning> button.

- copy values of the 4 weights into the following diagram.

- Have they been changed after training?

Testing (Usage)

 Click the <self drive> button.  The robot will use the learned intelligence to recognize the cards

- test with "Red"card

- test with "Green"card

- test with "Red" card

- Are the result correct?

- test with the cards many times and record the result

Discussion

Can the robot read the cards correctly and action correctly?

Has the robot gained intelligence after training?  How does you know?

Has learning been achieved?  How does you know?

Have the weights changed after the completion of training?

======

How many input neurons are there?

How many output neurons are there?

Can you draw the neural network with all connections shown?  Record the numbers on the connections for the learned AI.

What are the numbers on the connections?

======

Further discussion and work

- Learning is achieved during training, the weights are optimized which present occurrence of learning.  Discuss.

- For Advanced students, can you verify the relationship of the numbers (inputs, weights and outputs).

Appendix A

Sensors (Input) - Camera 2 x 1

Sensors (Input) - Red vs Green

Actions (Output) - Forward, Stop

Labeled Output - Green - Forward, Red - Stop.

AI Setting - no bias for the neurons (for easy verification of calculation)

Visualization - set "keep space between neurons" for easy checking of values