Assignments
Final: (due Friday May 12, 2023)
This is a take-home Final Exam. You may ask questions of the Professor or search Google. This is exam is to be completed independently. Submit your .html or .pdf file and your .qmd file for each Part.
Part 1: Make an Quarto notebook with the file name lastname_firstname_Stat654_final_part1.qmd and do the following:
Read the excellent blog post from the Data Science Heroes website, How to create a sequential model in Keras for R.
- Run all of the code in this blog post in your Quarto Notebook and explain each step presented. Clearly describe what kind of neural network is being fitted.
- Change the neural network to use units = 4 for the first hidden layer and units = 2 for the second layer. Change the number of epochs = 40 in the fit(). How well does this neural network perform compared to the original neural network run?
- Note the use of one-hot encoding in the code. What is one-hot encoding and why is it used in this code? Why is activation = “softmax” used in the output layer? How does this code differ from using activation = “sigmoid” in the output layer?
Part 2: Make an Quarto notebook with the file name lastname_firstname_Stat654_final_part2.qmd and do the following:
Go to Alex Krizhevsky website and look over the The CIFAR-10 dataset. This is an interesting dataset with 10 different labeled classes of images.
Run all of the code from the Posit Keras website Example cfar10 and explain each step presented. Clearly describe what kind of neural network is being fitted.
First change the number of epochs to a value <= 50 (current value is 50, at the top), so it does not run forever. This program will take a long time to run. Does it appear that it has run long enough?
Suggestions: If you are having a hard time Rendering your Notebook into an .html or .pdf this code may be beyond the capability of your computer hardware. Try to reduce the epoch variable to 50 or less, maybe 20, to see if that helps. If that does not solve the problem, run the code outside of a Notebook and copy the relevant code into a .docx file and add your comments to that file.
Part 3: Finally found a way to identify objects in a picture. The neural network to do this is called Yolo. Here is a blog post about how to use Yolo in R. Object detection in just 3 lines of R code using Tiny YOLO and the ggnot2 YouTube video Image Classification and Object Detection in R using just TWO lines of code!
To install the R package image.darknet you may need to download the install from the website:
https://github.com/bnosac/drat
- R notebook: 11_Yolo.zip
Suggestions: The main output to submit is the predictions.png file which is not visible when Rendering the Notebook. I would suggest submitting the .png file directly or copying the original image and the predictions.png file into a .docx file and add your comments.
Homework06: (not collected)
Using a Quarto Notebook produce your output from running the code from the book in Chapter . Render the .qmd files to either Lastname_Firstname_Stat652_hw3.docx or .pdf. Use your own last name and first name in the filename. At the top of your first page you should include Name, Class, Section, and homework assignment.
The header of your R Notebooks should include
title: "Stat. 654 Homework 6"
author: "Your name"
- Read: Chapter 10 and 12
- Read: Chapter 13 and 14.
Problems:
- Run as much of the code as you can on your computer from Chapter 10.
- Run as much of the code as you can on your computer from Chapter 12.
Homework05: (complete by Monday April 22, 2024)
The header of your R Notebooks should include
---
title: "Stat. 654 Homework 5"
author: "Your name"
date: "April 22, 2024"
format:
html:
self-contained: true
---
Submit: Submit your Quarto Notebooks or shared CoLab Notebooks. You can share the CoLab Notebooks with me by providing the links in Canvas. If you use Quarto Notebooks, you can submit both your .qmd and .html files.
- Template Quarto Notebooks:
- Read: Chapter 11 Problems:
- Run as much of the code as you can on your computer from Chapter 11.
Project: (due Monday April 29, 2024)
Make a stylized picture. Using AI/Neural Network.
The goal of the Project is to run the style transfer code from Chapter 12 Section 3 on a picture of interest to you using a style of painting you like.
Next get the code from Chapter 12 Section 3, Neural Style Transfer, to run.
- Step 1: Find the picture to apply the style transfer to.
- Step 2: Replace the sf.jpg image with your own image. Test the code using a smaller number of iterations, change iterations = 4000 to iterations = 200 to start experimenting with the code.
- Extra Credit: Research the algorithm used. Who created it? How is the neural network implemented in Keras?
- Extra Credit: Explain what the following text-to-image Generative AI products do.
- Test out. Microsoft Image Creator
- Example Style Transfer:
Submit: Submit your Quarto Notebooks or shared CoLab Notebooks. You can share the CoLab Notebooks with me by providing the links in Canvas. If you use Quarto Notebooks, you can submit both your .qmd and .html files.
- Template Quarto Notebook:
Midterm: (due Monday April 22, 2024)
Instructions: This is a take-home midterm. Your work is to be completed individually. You may use your book, Google, and questions can be asked of the instructor. You are not to share code with others in the class.
Using a Quarto Notebook produce your solutions to questions 1, 3, and 4. Turn in your modified Quarto Notebook for the IMDB code from Section 3.4 and an updated ver02 of the code provided for question 5, submit your .qmd and .html files. So you should submit three .qmd files and the corresponding .docx or .pdf files.
- Template Quarto Notebook:
- Explain what a tensor is in words. In words describe examples of 2D, 3D, 4D, and 5D tensors.
- Write you own explanation.
- Prompt Microsoft CoPilot or groq.com to generate an explanation.
- In Section 4.1 of the Deep Learning with R book, the IMDB example is presented. Explain what the data being fitted is and what the input layer does in the neural network used in that section. Run the code from that example, try adding dropout layer(s) to see if the fit can be improved.
- When using the Gradient Descent Algorithm and Backpropogation, in which direction do updates move?
- Write you own explanation.
- Prompt Microsoft CoPilot or groq.com to generate an explanation.
- Explain what a Convolutional Neural Network is in words. How does a convnet compare to the traditional feedforward neural network?
- Write you own explanation.
- Prompt Microsoft CoPilot or groq.com to generate an explanation.
- Run the code from the book, A Computational Approach to Statistical Learning, from Chapter 8 casl Chapter 8. This example is related to the EMNIST dataset. Read the sample chapter Chapter 8. Use Meld to merge the changes from ver01 into ver02 of the R Notebook. Your assignment is to run the code in ver02 and write clear explanations above each R code chunk. Be sure to explain what a Feed-forward Neural Network is and what the Convolutional layers are.
Question 5:
- R Project: Midterm.zip Updated, please download again.
- Spotlight Arxiv Paper: EMNIST: an extension of MNIST to handwritten letters
- Spotlight Software:
- Meld Compare text files.
Quiz: (due Monday April 15, 2024)
Build a Feed-Forward Neural Network, with one hidden layer, for the Palmer Penguins data using keras/tensorflow. Using the numeric columns in the penguins dataset, bill_length_mm, bill_depth_mm, flipper_length_mm, body_mass_g, build a classification model for the species variable. Add a dropout layer using a rate of .5 and compare the results without dropout.
Note that the NA values need to be dropped or imputed before scaling the data to be used as input in the Neural Network model. Neural Networks do not run with missing values. (Alternatively, try replacing the missing values with the value 0. Is this a legitimate way to handle missing values?)
See the iris code from Week 1 as a template. Change the iris data to the penguins data. And finally refit the model using a .5 dropout rate.
Submit: Submit your Quarto Notebooks or shared CoLab Notebooks. You can share the CoLab Notebooks with me by providing the links in Canvas. If you use Quarto Notebooks, you can submit both your .qmd and .html files.
- Template Quarto Notebook:
Homework04: (complete by Monday April 15, 2024)
Using a Quarto Notebook produce your output from running the code from the book in Chapter 8. Render the .qmd files to either Lastname_Firstname_Stat652_hw4.docx or .pdf. Use your own last name and first name in the filename. At the top of your first page you should include Name, Class, Section, and homework assignment.
The header of your R Notebooks should include
---
title: "Stat. 654 Homework 4"
author: "Your name"
date: "April 15, 2024"
format:
html:
self-contained: true
---
Submit: Submit your Quarto Notebooks or shared CoLab Notebooks. You can share the CoLab Notebooks with me by providing the links in Canvas. If you use Quarto Notebooks, you can submit both your .qmd and .html files.
- Template Quarto Notebooks:
- Read: Chapter 7 and Chapter 8 and Chapter 9
- Problems:
- Convnets MNIST
- Convnets Dogs vs Cats
Homework03: (complete by Monday April 8, 2024)
Using three Quarto or shared Colab Notebooks produce your output from running the code from the book in Chapter 3 and 4.
At the top of your first page of each Notebook you should include Name, Class, Section, and homework assignment.
The header of your Quarto Notebooks should include
---
title: "Stat. 654 Homework 3"
author: "Your name"
date: "April 8, 2024"
format:
html:
self-contained: true
---
Submit: Submit your Quarto Notebooks or shared CoLab Notebooks. You can share the CoLab Notebooks with me by providing the links in Canvas. If you use Quarto Notebooks, you can submit both your .qmd and .html files.
- Template Quarto Notebooks:
- Read: Chapter 5 and Chapter 6
- Problems:
- Watch the YouTube video series 3Blue1Brown Neural Networks
- You can download the code for the book from this link.
- Run the code in Chapter 5 related to the mnist data. Split the code into three Quarto Notebooks. Give a descriptive title to each Notebook. Copy the code into separate code chunks and explain what the code is doing directly above each code chunk.
Homework02: (complete by Monday March 25, 2023)
Using three Quarto or shared Colab Notebooks produce your output from running the code from the book in Chapter 4.
At the top of your first page of each Notebook you should include Name, Class, Section, and homework assignment.
The header of your Quarto Notebooks should include
---
title: "Stat. 654 Homework 2"
author: "Your name"
date: "March 25, 2024"
format:
html:
self-contained: true
---
Submit: Submit your Quarto Notebooks or shared CoLab Notebooks. You can share the CoLab Notebooks with me by providing the links in Canvas. If you use Quarto Notebooks, you can submit both your .qmd and .html files.
- Template Quarto Notebooks:
- Read: Chapter 3 and Chapter 4
- Problems:
- You can download the code for the book from this link.
- Make three separate Quarto Notebooks or shared Colab Notebooks for the three examples from Chapter 4. See the examples below, you will need to add comments.
- Binary classification, classifying-movie-reviews.R - Colab
- Multi-class classification, classifying-newswires.R Colab
- Regression, predicting-house-prices.R - Colab
Homework01: (complete by Monday March 18, 2024)
Using four separate Quarto or shared CoLab Notebooks produce your output from running the code from the examples and from the book Chapter 2.
At the top of your first page of each Notebook you should include Name, Class, Section, and homework assignment.
The header of your Quarto Notebooks should include
---
title: "Stat. 654 Homework 1"
author: "Your name"
date: "March 18, 2024"
format:
html:
self-contained: true
---
Submit: Submit four Quarto Notebooks or shared CoLab Notebooks. You can share the CoLab Notebooks with me by providing the links in Canvas. If you use Quarto Notebooks, you can submit both your .qmd and .html files.
- Template Quarto Notebooks:
- Read: Chapter 1 and Chapter 2
- Install R and RStudio, if you do not have them installed.
- For Windows users, install Python 3.11.8, scroll down to Files and select the Windows Recommended.
- For Mac users you should already have Python installed, so there is no reason to install it again. Update: It maybe that the current installed version of Python is too new for use with Tensorflow. If this is the case, run the reticulate::install_python() to download and install a version of Python that is compatible with Tensorflow. You may need to change the version to 3.11.8. If you have problems, please let me know.
- Install the R packages tensorflow and keras (for use with a CPU).
- Problems:
- Run the cars Example.
- Run the concrete Example.
- Run the iris Example.
- Run the code in Chapter 2 related to the mnist data. You can download the code for the book from this link. Copy the code into separate code chunks and explain what the code is doing directly above each code chunk.