Starting from:

$25

Introduction to Machine Learning Homework #5


1 Aim
Please classify the images with pre-trained CNN model(s) with , include top=False and
weights=’imagenet’ in keras.applications [1]. Please design your own top models. Since
the weights in the pre-trained model already be the up-to-best solution with respect to the
data set ImageNet, based on transfer learning concept [2], the general features can be caught
within these convolution and pool layers. The specialized features can be extracted by the
top-layer models. In this homework, you can refer to keras cnn example.py and choose one
or some pre-trained CNN model(s). Please also attach figure(s) or explain the original architecture of the pre-trained CNN model(s). You may apply new methods or use new packages
to improve the the quality of clustering, but if you do so, you have to give a brief introduction of the key concepts and provide necessary citations, instead of just direct copy paste
or importing. However, in this assignment, you must have a model utilizing the pre-trained
model offered in keras(ver 2.2).application or tensorflow(ver 1.8).contrib.keras.application.
In order to save your keras.model, please install h5py(ver. 2.8) with pip. Once the algorithm packages are merged or imported into your code, please list the package link in your
reference and describe its mathematical concepts in your report followed by the reason for
adoption.
12 Dataset Description
The folder in the ‘HW5 dataset.zip’ has cats and 10 monkey species photos. All of them
are selected from https://www.kaggle.com/crawford/cat-dataset [3] and
https://www.kaggle.com/slothkong/10-monkey-species [4]. Their labels are listed in the file
‘HW5 image labels.csv’. The label file has two label columns. ‘label 2’ stands for cats and
monkeys; while ‘label 11’ is used to separate the images into cats and 11 monkey species.
In the compressed file, there are two folders, train and test, for training and testing
models. The labels for images are listed in train labels.csv and test labels.csv.
3 Submission Format
You have to submit a compressed file hw5 studentID.zip which contains the following
files:
1. hw5 studentID.ipynb: detailed report, Python codes, results, discussion and mathematical descriptions;
2. hw5 studentID.tplx: extra Latex related setting, including the bibliography;
3. hw5 studentID.bib: citations in the ”bibtex” format;
4. hw5 studentID.pdf: the pdf version of your report which is exported by your ipynb
with
(a) %% jupyter nbconvert - -to latex - -template hw5 studentID.tplx
hw5 studentID.ipynb
(b) %% pdflatex hw5 studentID.tex
(c) %% bibtex hw5 studentID
(d) %% pdflatex hw5 studentID.tex
(e) %% pdflatex hw5 studentID.tex
5. Other files or folders in a workable path hierarchy to your jupyter notebook (ipynb).
4 Coding Guidelines
For the purpose of individual demonstration with TA, you are required to create a function code in your jupyter notebook, as specified below, to reduce the data dimensionality,
learn a classification model, and evaluate the performance of the learned model.
• hw5 studentID demo(in x=None,in y=None,label type=None,mode=None)
2{ in x: [string] a path to the homework image training and testing folders.
{ in y: [string] ‘csv’ file for the labels. The first column is image file name; the
others are the labels for classify image set to 2 groups or 11 groups.
{ label type: [int] determine which labels in ‘in y’ will be used to train. label type=2 use label 2; while label type=11 use label 11.
{ mode: [string] mode=‘train’ Train the model with ‘label 2’ in ‘in y’ if ‘label type=2’; with ‘label 11’ in ‘in y’ if ‘label type=11’. After training, please utilize keras to save the top model designed by you to ‘HW5 studentID model 2.h5’
or ‘HW5 studentID model 11.h5’ corresponding to ‘label 2’ or ‘label 11’ respectively. Save the overall model and batch size as global.
Please also output ‘HW5 studentID parameter 2.csv’ and ‘HW5 studentID parameter 11.csv
files with header ‘pre-trained-model’ to list when ‘label type=2’ or ‘label type=11’
which pre-trained model in keras.application is used. As to the model name, please
refer to the table in [1]. In demonstration, use dropout method to train the top
model.
label type 2 11
output top model HW5 studentID model 2.h5 HW5 studentID model 11.h5
output parameter HW5 studentID parameter 2.csv HW5 studentID parameter 11.csv
mode=‘test’ Used the combined model (pre-trained model in keras and your topmodel) to predict the labels of test set. W.r.t. label type’. please output the accuracy to ‘HW5 studentID accuracy 2.csv’ or ‘HW5 studentID accuracy 11.csv’
record the predicted labels with header ‘labels’ in ‘HW5 studentID results 2.csv’
or ‘HW5 studentID results 11.csv’. Remember the labels in the ‘*results*.csv’
should matched to ‘in y’. In accuracy files, there will be only one float number. Please show in ‘%’. For example, if the accuracy is 95.0001%, please output
95.0001.
label type 2 11 header
accuracy HW5 studentID accuracy 2.csv HW5 studentID model 11.h5 None
parameter HW5 studentID results 2.csv HW5 studentID results 11.csv ‘labels’
The score of the demonstration has two parts, the classification with label type=2 and
label type=11. For each part, the score will be graded by the ranking of accuracy for the
test dataset via your models. In the script file ‘hw5 studentID.py’, please add the following
code to your program before you import keras.
import tensorflow as tf from keras.backend.tensorflow backend
import set session config = tf.ConfigProto()
config.gpu options.allow growth = True
set session(tf.Session(config=config))
Note: the script you submit in demonstration will be referred when TA is grading your
report and jupyter notebook. Make sure TA knows how to modify your code if TA can not
execute your jupyter notebook properly.
35 Report Requirement
• List names of packages used in your program.
• Architecture of your model, including the pre-trained model(s) you used.
• Compare and conclude the test results w/o dropout for both ‘label type=2’ and ‘label type=11’.
• If you apply multiple pre-trained models, you may extend your report. For each classification, please just apply one pre-trained model.
5.1 Basic Requirement
• Apply your model with the pre-trained model with weights=‘imagenet’ and include top=False
in keras.application.
• Design the top model with and without dropout method to complete the classification.
• Please make sure hw5 student ID demo is functional and can output the required
files in both mode=‘train’ and mode=‘test’.
• If you apply new methods or use new packages to improve the classification performance, you have to give a brief introduction of the key concepts and provide necessary
citations/links, instead of just direct copy paste or importing.
• Please submit your ‘report’ in English. Be aware that a ‘report’ is much more than a
‘program.’
References
[1] pre-trained models in keras. https://keras.io/applications/. Accessed: 2018-06-14.
[2] transfer learning in cnn. http://cs231n.github.io/transfer-learning/. Accessed:
2018-06-14.
[3] cat dataset in kaggle. https://www.kaggle.com/crawford/cat-dataset. Accessed:
2018-06-14.
[4] 10-monkey-species in kaggle. https://www.kaggle.com/slothkong/
10-monkey-species. Accessed: 2018-06-14.
4

More products