Data Lab 4: Neural Network in Python
1. Assignment 1:
Continuing from yesterday's video lecture series, today you will be studying the implementation details in python
open the python notebook for the flower classification problem and try to understand the code. For reference feel free to go through the video explaining the implementation steps
Pro Tip !!
Take notes of what new concepts are being discussed. You can take notes in the DL-notes.docx file in your Block C Microsoft Teams assignment. This notes document is automatically part of your evidence for assessment.
Assignment 2:
Make a copy of the implementation above and create your own google colab copy as NeuralNetwork-InPython.ipynb in Block C Github repository.
2a For this assignment, you will modify the code above to do a gender classification.
Here is the dataset you need to use for training and testing your neural network
# data format
# height, weight, genderType
# genderType = 0 <- Female
# genderType = 1 <- Male
# from the first entry [1.74,.96,1] it means height= 1.74 meters, weight= 96 kgs, Male
train_data = [[1.74,.96,1],
[1.89,.87,1],
[1.49,.61,1],
[1.89,1.04,1],
[1.74,.90,1],
[1.69,1.03,0],
[1.53,1.07,0],
[1.57,1.10,0],
[1.53,1.49,0],
[1.85,1.10,0],
[1.87,.62,1],
[1.78,.52,1],
[1.60,1.31,0],
[1.57,1.53,0],
[1.89,1.32,0],
[1.44,.80,1],
[1.71,1.52,0],
[1.75,1.20,0],
[1.49,1.08,0],
[1.57,.56,1],
[1.82,1.26,0],
[1.85,.76,1],
[1.88,1.22,0],
[1.61,.72,1],
[1.68,1.35,0]]
test_data = [[1.90, .95, 1], #MALE
[1.63, 1.59, 0], #FEMALE
[1.72, .92, 1], #MALE
[1.41, 1.43, 0]] #FEMALE
In your DL-notes.docx file in your Block C Microsoft Teams assignment. answer the following questions
2b which variable can you update in the program to get various accuracy results?
2c [optional] what changes you have to make in your code to change the activation function to use tanh activation function?
2d take note of your optimal hyper parameter values and your final accuracy, and provide some comments justifying the values.
2e Use this dataset and expand your Model to include "body index" feature for gender classification.
2f [optional] Try out the above exercise with 2 neurons instead of 1, and discuss the differences.
Next steps
Next week you will learn how to use TensorFlow library to build your neural network. The networks will grow much bigger, more neurons, more features .. everything more !! . Luckily, there will be less python coding, and no maths. Tensorflow has all the features build into it and you will just need to call the correct steps. The important takeaway, from this week are the tensors and understanding of the foundation concepts of a neural net. And ofcourse, getting some python coding practice in the way is always fun :) !!
By the way, here is a demo of all neurons in action to classify a digit, you will get there next week : https://www.cs.ryerson.ca/~aharley/vis/fc/