Hello, if you have any need, please feel free to consult us, this is my wechat: wx91due
COMP1002/8802 – Lab 9 Worksheet
Part 1 – TensorFlow Playground
This website will allow you to try different neural network architectures, composed of several artificial neurons separated into layers, on a variety of datasets. Each neuron outputs either 0 or 1, based on the combined (weighted) sum of its inputs. For this worksheet, we are going to be looking at the problem of Classification. This means that we have a collection of training data that is labelled into categories, in this case the dots in our data are labelled as either blue or orange. By looking at how the features of each dot (in this case it’s x and y coordinates) correspond with its colour, our neural network will attempt to predict the colour of any new dots we provide it with. This is the same general idea as when we used the features of passengers on the titanic to determine whether they died or survived, except this time we are using a dots position to try and predict its colour.
Part 2 – Neurons
Let’s start by looking at a very simple problem with a single neuron. Select the Gaussian (bottom left) dataset on the left-hand side of the website and reduce our neural network to a single hidden layer with a single neuron. Also select the “Discretize output” checkbox in the bottom right corner. Click the Play ( ) button in the top left corner to begin training our neural network.
After a short time, our neural network will converge on a model that accurately separates the orange and blue dots. Any dot that falls into the orange or blue areas of the output will be classified accordingly.
Hovering our mouse cursor over the lines in our network reveals their weights, and hovering over the small dot in the bottom left of our neuron reveals its bias. In this example case (your results may differ) we can see that the corresponding weights & bias for our neuron are:
As our network is just a single neuron, we can easily verify our neural network’s output for several example inputs (if neuron fires then our prediction is blue, otherwise orange).
Try running the same neural network on some of the other datasets. You should see that our single neuron network is not able to accurately classify all the dots. This is because a single neuron with just the x and y coordinates as input is only able to produce a linear line of separation. To accurately classify more complex patterns, we will also need to add additional neurons to our neural network.
Part 3 – Additional Neurons (marked)
- Question: How many neurons in a single layer are needed to accurately classify (test loss < 0.03) each of the following datasets:
- Circle (top left)
- Exclusive or (top right)
- Gaussian (bottom left)
Part 4 – Neuron Layers (marked)
- Question: How many neurons in total (across multiple layers) are needed to accurately classify (test loss < 0.03) each of the following datasets:
- Spiral (bottom right)
Part 5 –Network Training (marked)
Create a neural network with a single hidden layer containing 4 neurons. Using the default learning rate of 0.03, see how many epochs it takes for the model to find an accurate solution for the circle dataset. You can press the step button next to the play button to advance a single epoch. Reset the network and repeat this process several times to get a range of results.
- 0.003
- 0.03
- 0.3
- 3
- Is there a difference in the shape of the output pattern for each of these learning rates?
Part 6 – Feature Engineering (marked)
TensorFlow Playground provides the following augmented features:
Return your learning rate to 0.03, and experiment with adding or removing different input features and see how this affects your network for different datasets.
- Circle (top left)
- Exclusive or (top right)
- Spiral (bottom right)
Bonus 1 – Additional Neural Network Options
Activation:
By default, no noise is added to our training data. This makes our pattern boundaries very clear but is also not representative of many real-world datasets. Adding noise to our dataset will add some more variance to our data points, blurring the pattern boundaries.
By default, the ratio of training data (that is used to train the neural network) to test data (that is used to evaluate the neural network’s accuracy) is / . It is important that we keep some of our available data separate for testing the network, otherwise we will be unable to tell if our model is overfitting. You should see that if our ratio decreases to 10%, our test loss will be significantly higher. This indicates that the model is overfitting to our limited training data and performing poorly on the test data. This effect is especially obvious for the circle dataset, where our model will often not form the ideal circular pattern.
The purpose of regularization is to reduce overfitting and help generalise the model. Overfitting is when a model works well for the data that it was trained on but performs poorly on test data it hasn’t seen before.
- L1 regularization (aka. Lasso) tries to keep the majority of the edge weights close to 0.A higher regularization rate will also make the regularization effect stronger.