Starting from:
$30

$24

Homework #5 Solution




Please submit your homework report to iLMS before 23:59 on Jun 20. Please go to the shared Google document ‘hw4 5 demo registration’ , which I have announced in the HW#4 assignment, to reserve a time slot for an individual demonstration with TA. You are encouraged to consult or collaborate with other students while solving the homework problems, however you are required to turn in your own version of the report and programs written in your own words with supporting materials. Copying will not be tolerated.










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 archi-tecture 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 introduc-tion 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 tensor ow(ver 1.8).contrib.keras.application. In order to save your keras.model, please install h5py(ver. 2.8) with pip. Once the algo-rithm 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.

























1









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.










Submission Format



You have to submit a compressed file hw5 studentID.zip which contains the following files:













hw5 studentID.ipynb: detailed report, Python codes, results, discussion and math-ematical descriptions;



hw5 studentID.tplx: extra Latex related setting, including the bibliography;



hw5 studentID.bib: citations in the ”bibtex” format;



hw5 studentID.pdf: the pdf version of your report which is exported by your ipynb with






%% jupyter nbconvert - -to latex - -template hw5 studentID.tplx hw5 studentID.ipynb



%% pdflatex hw5 studentID.tex



%% bibtex hw5 studentID



%% pdflatex hw5 studentID.tex



%% pdflatex hw5 studentID.tex



Other files or folders in a workable path hierarchy to your jupyter notebook (ipynb).









Coding Guidelines



For the purpose of individual demonstration with TA, you are required to create a func-tion 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. la-bel 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 ‘la-bel type=2’; with ‘label 11’ in ‘in y’ if ‘label type=11’. After training, please uti-lize 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’ respec-tively. 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 top-model) to predict the labels of test set. W.r.t. label type’. please output the ac-curacy 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 num-ber. 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.




3









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 ‘la-bel type=11’.




If you apply multiple pre-trained models, you may extend your report. For each clas-sification, 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 perfor-mance, 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




pre-trained models in keras. https://keras.io/applications/. Accessed: 2018-06-14.



transfer learning in cnn. http://cs231n.github.io/transfer-learning/. Accessed: 2018-06-14.






cat dataset in kaggle. https://www.kaggle.com/crawford/cat-dataset. Accessed: 2018-06-14.






10-monkey-species in kaggle. https://www.kaggle.com/slothkong/ 10-monkey-species. Accessed: 2018-06-14.
























4

More products