evaluation.py

# Handwritten digit recognition for MNIST dataset using Convolutional Neural Networks # Step 1: Import all required keras libraries from keras.models import load_model # This is used to load your saved model from keras.datasets import mnist # This is used to load mnist dataset later from keras.utils import np_utils # This will be used to convert your test image to a categorical class (digit from 0 to 9) # Step 2: Load and return training and test datasets def load_dataset(): # 2a. Load dataset X_train, X_test, y_train, y_test via imported keras library # 2b. reshape for X train and test vars - Hint: X_train = X_train.reshape((X_train.shape[0], 28, 28, 1)).astype('float32') # 2c. normalize inputs from 0-255 to 0-1 - Hint: X_train = X_train / 255 # 2d. Convert y_train and y_test to categorical classes - Hint: y_train = np_utils.to_categorical(y_train) # 2e. return your X_train, X_test, y_train, y_test # Step 3: Load your saved model # Step 4: Evaluate your model via your_model_name.evaluate(X_test, y_test, verbose = 0) function # Code below to make a prediction for a new image. # Step 5: This section below is optional and can be copied from your digitRecognizer.py file from Step 8 onwards - load required keras libraries from keras.preprocessing.image import load_img from keras.preprocessing.image import img_to_array # Step 6: load and normalize new image def load_new_image(path): # 6a. load new image newImage = load_img(path, grayscale=True, target_size=(28, 28)) # 6b. Convert image to array newImage = img_to_array(newImage) # 6c. reshape into a single sample with 1 channel (similar to how you reshaped in load_dataset function) # 6d. normalize image data - Hint: newImage = newImage / 255 # 6e. return newImage # Step 7: load a new image and predict its class def test_model_performance(): # 7a. Call the above load image function img = load_new_image('your_new_image_file_path') # 7b. load your CNN model (digitRecognizer.h5 file) # 7c. predict the class - Hint: imageClass = your_model_name.predict_classes(img) # 7d. Print prediction result print(imageClass[0]) # Step 8: Test model performance here by calling the above test_model_performance function

sample_images/digit1.png

sample_images/digit2.png

sample_images/digit3.png

sample_images/digit4.png

sample_images/digit5.png

sample_images/digit6.png

sample_images/digit7.png

sample_images/digit8.png

sample_images/digit9.png

digitRecognizer.py

# Handwritten digit recognition for MNIST dataset using Convolutional Neural Networks # Step 1: Import all required keras libraries from keras.datasets import mnist # This is used to load mnist dataset later from keras.utils import np_utils # This will be used to convert your test image to a categorical class (digit from 0 to 9) # Step 2: Load and return training and test datasets def load_dataset(): # 2a. Load dataset X_train, X_test, y_train, y_test via imported keras library # 2b. reshape for X train and test vars - Hint: X_train = X_train.reshape((X_train.shape[0], 28, 28, 1)).astype('float32') # 2c. normalize inputs from 0-255 to 0-1 - Hint: X_train = X_train / 255 # 2d. Convert y_train and y_test to categorical classes - Hint: y_train = np_utils.to_categorical(y_train) # 2e. return your X_train, X_test, y_train, y_test # Step 3: define your CNN model here in this function and then later use this function to create your model def digit_recognition_cnn(): # 3a. create your CNN model here with Conv + ReLU + Flatten + Dense layers # 3b. Compile your model with categorical_crossentropy (loss), adam optimizer and accuracy as a metric # 3c. return your model # Step 4: Call digit_recognition_cnn() to build your model # Step 5: Train your model and see the result in Command window. Set epochs to a number between 10 - 20 and batch_size between 150 - 200 # Step 6: Evaluate your model via your_model_name.evaluate() function and copy the result in your report # Step 7: Save your model via your_model_name.save('digitRecognizer.h5') # Code below to make a prediction for a new image. # Step 8: load required keras libraries from keras.preprocessing.image import load_img from keras.preprocessing.image import img_to_array from keras.models import load_model # Step 9: load and normalize new image def load_new_image(path): # 9a. load new image newImage = load_img(path, grayscale=True, target_size=(28, 28)) # 9b. Convert image to array newImage = img_to_array(newImage) # 9c. reshape into a single sample with 1 channel (similar to how you reshaped in load_dataset function) # 9d. normalize image data - Hint: newImage = newImage / 255 # 9e. return newImage # Step 10: load a new image and predict its class def test_model_performance(): # 10a. Call the above load image function img = load_new_image('your_new_image_file_path') # 10b. load your CNN model (digitRecognizer.h5 file) # 10c. predict the class - Hint: imageClass = your_model_name.predict_classes(img) # 10d. Print prediction result print(imageClass[0]) # Step 11: Test model performance here by calling the above test_model_performance function

NRSG371: Building Healthy Communities

NRSG371_ Assessment task 2: Written Assignment _ © Australian Catholic University 2021

ASSESSMENT 2 INFORMATION

Assessment type: Written assignment - Essay

Purpose

This assessment task addresses health problems as a societal issue. It requires you to integrate the role of the nurse with the building of healthy communities in order to expose you to the reality that nursing practice environments reach beyond the hospital setting into the wider community.

Due Date: Week 12, Wednesday, 26th of May 2021

Time Due 0900hrs

Weighting 50%

Length 2000 words +/- 10% (includes intext citations, excludes reference list)

Assessment Rubric Appendix B of unit outline

LOs Assessed LO3, LO4, LO5

Task

Describe how nurses can work in partnership with the community of your choice (within Australia), using a strength-based approach, to address one of the following topics Topic and definitions Homelessness Homelessness in Australia is a widespread and largely preventable issue. This public health concern presents a systematic flow on affect to the wider community (Australian Government Department of Health, 2019).

Infectious diseases Infectious diseases have the potential to cause devastation to an entire community at any given time and without warning (Australian Government Department of Health, 2020).

Gender Knowledge of clinically significant sex and gender differences in screening, risk factors, treatment and prognosis are emerging across a broad range of diseases, and differences are identified for those conditions conferring the greatest health burden in Australia and globally (Wainer & Carcel 2019).

Target Audience Health care professionals

Submission Turnitin, word document files only

NRSG371: Building Healthy Communities

NRSG371_ Assessment task 2: Written Assignment _ © Australian Catholic University 2021

FORMATTING

File format Word document

Margins 2.54cm, all sides

Font and size 11-point Calibri or Arial

Spacing Double spacing

Paragraph Aligned to left margin, indent first line of each paragraph 1.27cm

Title Page Not to be used

Level 1 Heading Centered, bold, capitalize each word (14-point Calibri or Arial)

Level 2 Headings Flush left, bold, capitalize each word (12-point Calibri or Arial)

Structure Introduction, main paragraphs, conclusion, reference list

Direct quotes Always require page number. No more than 10% of WC in direct quotes

Header Page number top right corner (9 point Calibri or Arial)

Footer Name _ Student Number_ Assessment _ Unit _ Year (9 point Calibri or Arial)

REFRENCING

Referencing Style APA 7th

Minimum References 10-15

Age of References Published in the last 5 years as this area of knowledge is rapidly developing

List Heading “References” is centered, bold, on a new page. (14 point Calibri or Arial)

Alphabetical Order References are arranged alphabetically by author family name

Hanging Indent Second and subsequent lines of a reference have a hanging indent

DOI Presented as functional hyperlink

Spacing Double spacing the entire reference list, both within and between entries

ADMINISTRATION

Late Penalties

Late penalties will be applied from 9:01am on the 26th of May 2021, incurring 5% penalty of the maximum marks available up to a maximum of 15%. Assessment tasks received more than three calendar days after the due or extended date will not be allocated a mark. Example: An assignment is submitted 12 hours late and is initially marked at 60 out of 100. A 5% penalty is applied (5% of 100 is 5 marks). Therefore, the student receives 55 out of 100 as a final mark. Penalty Timeframe Penalty Marks Deducted 9:01 am Wednesday to 9 am Thursday 5% penalty 5 marks 9:01am Thursday to 9am Friday 10% penalty 10 marks 9:01am Friday to 9am Saturday 15% penalty 15 marks Received after 9:01 Saturday No mark allocated n/a

Return of Marks Marks will be generally returned in three weeks; if this is not obtainable, you will be notified via your campus LEO forum.

Final Assignment Marks for the final assessment – this assessment, will be withheld until after grade ratification and grade release on the 2nd July 2021.

Assignment 2 (15% of total course weight) – Computer vision with CNNs

California State University San Bernardino, School of Computer Science and Engineering (CSE)

Date of Issue: May 1, 2021, Date of submission: May 19, 2021 – 11:59 pm (PST)

Module: CSE 5120 Introduction to Artificial Intelligence

Assessment brief: We have covered the power of deep learning in real-world object detection and recognition in our course that included the use of Artificial Neural Networks (ANNs) and their successors Convolutional Neural Networks (CNNs). Object recognition in image/video data is an increasingly famous example of the harnessing the power of deep learning in solving real-world problems. This assignment requires designing the most basic example of object recognition for machine and deep learning which will be based on handwritten digit recognition using CNNs. The dataset to be used for this assignment comprises of 70,000 images of preprocessed images of digits scanned from the large number of documents by the National Institute of Standards and Technology (NIST). We will use this modified NIST (MNIST) dataset and implement a CNN model that should achieve near state-of-the-art performance in Python using Keras deep learning library.

After completing this assignment, you will have expert skills on:

· Loading the MNIST dataset in Keras.

· Developing near state-of-the-art deep learning model for MNIST using CNNs.

Your assignment is based on two parts as given below:

1. Code implemented for handwritten digit recognition (MNIST) via CNNs in given digitRecognizer.py and evaluation.py files in Files_to_edit_and_sample_images.zip folder.

2. A brief report on what you did for your digit recognition model (i.e., how you implemented with screenshots)

File Name

Description

digitRecognizer.py

Where all of your handwritten digit recognition code via CNNs for MNIST dataset will reside. In this file, you will need to implement your CNN model from scratch using Keras deep learning library. At the end of this file, you should save your model and upload your saved model (.h5 file). This will be used to load your trained model, recognize digits of test cases, and print your model score in the output window. You should also print model accuracy and your model predictions through your code in this file and copy them in your assignment report (wherever needed in the report)

evaluation.py

The evaluation file where you will implement your code to load your model, run it on test cases for MNIST dataset, and print your model score.

digitRecognizer.h5

This will be the trained model (CNN) on MNIST dataset that you will produce in your digitRecognizer.py file using Keras built-in functions model.save(‘digitRecognizer.h5’) and load_model(digitRecognizer.h5’)

Assignment Report.doc

Report explaining your work for all the above work with description and screenshots. See below for more details

You can use Spyder (installed through Anaconda from week 1 Thursday’s lecture) or other IDE.

Files to Edit and Submit: You will need to edit and submit (digitRecognizer.py) file which will consist of your CNN model for MNIST dataset. You can copy and paste all the necessary pieces of code that we discuss here in the Assignment details section. Once you have completed the implementation of your model in this file, you should save your model with the name “digitRecognizer.h5” and upload it in Zipped folder in your assignment. To load your model, you can do the import “from keras.models import load_model” library from Keras. Once completed your digitRecognizer.py, you will need to implement the code in evaluation.py file to load your model (i.e., digitRecognizer.h5) via load_model, predict the classes for the test cases via the function already implemented in evaluation.py and print your predictions. For the development of your CNN model, please refer to the flowchart given in Assignment details section and the code we covered in Week 13 for CNNs implemented for cat/dog classification. You will need to test your model with evaluation.py to copy screenshots in your report.

Academic Dishonesty: Your code will be checked against other submissions in the class for logical redundancy. If you copy someone else’s code and submit it with minor changes, they will be detected, so please do not try that, and submit your own work only. In case of cheating, the University’s academic policies on cheating and dishonesty will strictly apply which may result from the deduction in your grade to expulsion.

Getting Help: If you are having difficulty in implementing your CNN model, contact course staff for help and refer to the content recorded and uploaded in Week 13 part 2 (Thursday) on Computer Vision using CNNs). Office hours and Slack are there for your support. If you are not able to attend office hours, then please inform your instructor to arrange for additional time. The intent is to make this assignment rewarding and instructional, not frustrating and demoralizing. You can either complete this assignment on your own or discuss the problem and collaborate with another member of the class (or different section). Please clearly acknowledge and mention your group member in your assignment report submission who you will collaborate with in this assignment. Your report and program (digitRecognizer.py, evaluation.py files and digitRecognizer.h5 model) will be separately submitted by yourself on Blackboard irrespective of your collaboration with your group member. Group discussions are encouraged but copying of programs is NOT allowed. Programming based on your own skills is encouraged.

1

Assignment Details

1. Modified National Institute of Standards and Technology (MNIST) dataset

The MNIST dataset was compiled and processed by Yann LeCun, Corinna Cortes and Christopher Burges to develop and evaluate new machine learning models on handwritten digit classification problem. The dataset was constructed from scanned document dataset available from the NIST, therefore naming it to Modified NIST (MNIST). As discussed in the class, the images of digits were taken from a variety of scanned documents, and then normalized in size and centered for model development. Image data preprocessing already makes the dataset in nearly ready form requiring little to no cleaning/augmentation task unlike we experienced in cat/dog classification task in Week 13. Each image in the dataset is a 28 × 28 pixel square, with a total of 784 pixels. When you load the dataset via Keras library in your code, you will realize that the dataset is already divided into train and test splits. There is a total of 70,000 images where 60,000 images are used to train a model and a separate set of 10,000 images are used to test it.

To date, various models including the CNNs have been developed with near state-of-the-art accuracy of above 99%. You have also seen a live demonstration of handwritten digit recognition via the web in the class. Your task will be to develop your own similar CNN for handwritten digit recognition via Keras library in Python. With a fairly larger CNN (see section 2 for implementation), it is expected that you will achieve an accuracy of nearly or even above 97% with <3% classification error. To learn how to load and assign train/test portions of the data, please visit this web page:

2. Convolutional Neural Network (CNN) for MNIST dataset – 15%

Please see below flowchart to implement your CNN model. For more details, please see the empty digitRecognizer.py file with comments to implement your code, and review code example covered in Week 13 on Computer Vision using Convolutional Neural Networks (CNN) with the example of cat/dog classification. Please note that you might need to change your CNN settings (i.e., number of Conv filters in each layer, number of units in each Dense layer or even adding/removing Conv/Dense layers) to achieve the accuracy of 97% or above.

Note: For model evaluation, you can use built-in Keras model evaluation function by writing code like model.evaluate(X_test, y_test, verbose=0). For this work, please write the description of your work in the report (2-page maximum) that may include your modifications in the CNN structure, or the description of your CNN even if you did not make any modification in the structure but still were able to get the accuracy of >97%. Use screenshots wherever needed.

Evaluation: You will copy the code in your evaluation.py file to only load your saved model from digitRecognizer.py file, use your saved model and make prediction on a few test images given in the assignment folder.

3. Assignment Report – 15%

Your report will be based on your explanation on MNIST dataset which will include your explanation of your CNN model implementation. You can even propose your own test images of custom drawn images (from 0 to 9) in a software of your own choice (e.g., digits drawn in MS paint with black background and white digit pixels). Please use screenshots (or manually edited versions) of your model training process to support your explanation. Your model training process should print 10 epochs with model metrics.

Assignment 2 (15%)

 

 

 

CSE 5120 (Section ##) – Introduction to Artificial Intelligence – Spring 2021 

 

 

Submitted to  

Department of Computer Science and Engineering California State University, San Bernardino, California 

 

by

Student name (CSUSB ID)

(Your collaborator in this homework (if any))

 

 

Date: Month Day, Year

 

 

 

 

 

 

Email:

· Your email

· Your collaborator’s email (if you collaborated with any)

Assignment Report

Brief description of your work here acknowledging your collaboration with your class fellow (or a friend from other CSE 5120 section), and the capacity at which he/she collaborated with you, followed by the algorithms you implemented.

1. digitRecognizer.py for MNIST dataset

Your brief explanation of the dataset, your code solution, and any documentation with screenshots of your code Evaluation (results from digitRecognizer.py)

2. Evaluation (evaluation.py) for your model performance evaluation

You can also provide brief description of your code written in evaluation.py to load your saved model that can be readily used on test dataset for the staff.

MNIST DatasetConvolution2D + ReLU(30filters, size = 5î5)MaxPooling2D(Pool size = 2, Strides = 2)Convolution2D + ReLU(15 filters, size = 3î3)MaxPooling2D(Pool size = 2, Strides = 2)Dropout(Probability 20%)FlattenDense (128 units + ReLU)Dense(50units)+ReLUDense (10 units) + softmaxDo prediction hereYou will need to reshape your train/test images to 28î28 pixels and then normalize them (e.g., Xtrain=Xtrain/255)You will need to reshape new unseen image for prediction to 28î28 pixels and then normalize it (e.g., newImage=newImage/255)

Get help from top-rated tutors in any subject.

Efficiently complete your homework and academic assignments by getting help from the experts at homeworkarchive.com