Understanding Deep Neural Networks
Total Page:16
File Type:pdf, Size:1020Kb
Bachelor thesis (Computer Science BSc) Understanding Deep Neural Networks Authors David Kempf Lino von Burg Main supervisors Dr. Thilo Stadelmann Prof. Dr. Olaf Stern Date 08.06.2018 DECLARATION OF ORIGINALITY Bachelor’s Thesis at the School of Engineering By submitting this Bachelor’s thesis, the undersigned student confirms that this thesis is his/her own work and was written without the help of a third party. (Group works: the performance of the other group members are not considered as third party). The student declares that all sources in the text (including Internet pages) and appendices have been correctly disclosed. This means that there has been no plagiarism, i.e. no sections of the Bachelor thesis have been partially or wholly taken from other texts and represented as the student’s own work or included without being correctly referenced. Any misconduct will be dealt with according to paragraphs 39 and 40 of the General Academic Regulations for Bachelor’s and Master’s Degree courses at the Zurich University of Applied Sciences (Rahmenprüfungsordnung ZHAW (RPO)) and subject to the provisions for disciplinary action stipulated in the University regulations. City, Date: Signature: …………………………………………………………………….. …………………………..………………………………………………………... …………………………..………………………………………………………... …………………………..………………………………………………………... The original signed and dated document (no copies) must be included after the title sheet in the ZHAW version of all Bachelor thesis submitted. Zurich University of Applied Sciences Abstract Artificial Intelligence (AI) comprises a wealth of distinct problem solving methods and attempts with its various subfields to tackle different classes of challenges. During the last decade, huge advances have been made in the field and, as a consequence, AI has achieved great results in machine translation and computer vision tasks. In particular, Artificial Neural Networks (ANNs) won several international con- tests in pattern recognition between 2009 and 2012 and even reached human-competitive performance in recognition applications. Despite these impressive achievements, ANNs are still often perceived as incomprehensible black boxes due to the complexity of the underlying models. As ANNs find their way more and more into everyday processes, the need for understanding their inner workings is becoming central. This thesis therefore surveys the state of the art in debugging Convolutional Neural Networks (CNNs) and explores the question how helpful the explanations provided by such methods are to improve the understanding of these classifiers. In order to investigate this question, an experimental testbed for applying debugging methods to CNNs was built and an experiment to evaluate these methods was carried out. An image recognition task related to the classification of cats and dogs served as a basis to conduct the investigation. The goal was to analyze how the model arrives at its classification scores when it is presented with input images that belong to neither of the classes it was trained to detect. When using debugging methods for better understanding the function of CNNs, it is important that the results obtained from such methods do explain not only reasons for assigning a given image to a specific output class but also reasons for not assigning it to a different output class. In this way, the results faciliate the understanding of the notion of classes that a CNN has developed from the data used to train it. Hence, part of the conducted experiment was to compare how differently the trained network behaves when it is fed with data that does not contain concepts corresponding to the output classes. Within the context of this work, state-of-the-art methods for debugging CNNs were reviewed and subsumed into a new taxonomy. A characteristic subset of these methods was applied to a CNN trained on the kaggle dogs vs cats competition dataset. ii Zusammenfassung Künstliche Intelligenz (KI) umfasst eine Vielzahl von verschiedenen Problemlösungsmethoden und ver- sucht mit seinen Unterbereichen unterschiedliche Klassen von Herausforderungen anzugehen. Während der letzten Dekade konnten in diesem Forschungsfeld sehr grosse Fortschritte verzeichnet werden und in der Folge hat KI sehr gute Ergebnisse in maschineller Übersetzung und maschinellem Sehen er- reicht. Insbesondere künstliche neuronale Netze (KNNs) gewannen im Zeitraum zwischen 2009 und 2012 zahlreiche internationale Wettbewerbe in Mustererkennung und erreichten sogar menschenähnliche Leistungen in Erkennungs-Anwendungen. Trotz dieser beeindruckenden Erfolge werden KNNs aufgrund der Komplexität der zugrundeliegenden Modelle immer noch oft als unverständliche Blackboxes aufge- fasst. Je mehr KNNs Teil der alltäglichen Prozesse werden, umso notwendiger wird es ein Verständnis ihrer inneren Funktionsweise zu haben. Diese Bachelorarbeit begutachtet deshalb den State of the Art, um Convolutional Neural Networks (CNNs) zu debuggen und untersucht die Frage, wie hilfreich die Erklärungen solcher Methoden dabei sind ein besseres Verständnis von diesen Klassifikatoren zu gewinnen. Um diese Frage zu untersuchen wurde eine experimentelle Testumgebung für das Anwenden von Debug- ging Methoden auf CNNs aufgebaut und ein Experiment für die Evaluation dieser Methoden durchge- führt. Ein Bilderkennungstask in Verbindung mit der Klassifizierung von Katzen und Hunden diente dabei als Basis, um die Untersuchung durchzuführen. Dabei war das Ziel zu analysieren, wie das trainierte Modell zu seinen Klassifikationsscores kommt, wenn als Input für das Netzwerk Bilder genom- men werden, die zu keiner der Outputklassen zugehörig sind. Wenn Debugging Methoden benutzt werden, um die Funktion von CNNs besser zu verstehen, dann ist es wichtig, dass die von solchen Methoden erhaltenen Ergebnisse nicht nur die Gründe erklären, wieso ein gegebenes Bild zu einer spezifischen Outputklasse zugeordnet worden ist, sondern auch die Gründe, wieso das gleiche Bild nicht einer anderen Outputklasse zugeordnet worden ist. Auf diese Weise verbessern die Resultate das Verständnis dafür, was für eine Vorstellung der Klassen das CNN aus den Trainingsdaten entwickelt hat. Daher wurde in einem Teil des Experiments verglichen, wie anders sich das Netzwerk verhält, wenn Daten eingegeben werden, die nicht den Outputklassen entsprechen. Im Rahmen dieser Arbeit wurden State-of-the-Art Methoden für das Debuggen von CNNs überprüft und in eine neue Taxonomie eingeordnet. Eine charakteristische Auswahl dieser Methoden wurde auf ein CNN angewendet, das auf dem dogs vs cats Wettbewerbsdatensatz trainiert worden ist. iii Preface Acknowledgement Our supervisor Dr. Stadelmann provided us with many inputs and practical tips while we were working on this Bachelor thesis. We would like to thank Dr. Stadelmann for all his support during the whole work. We thank our second supervisor Prof. Dr. Stern for reviewing the drafts of our report and giving us feedback for it. We would further like to express thanks to Mrs. Fernando for giving us language-related advice. We would also like to thank Mr. Amirian for his support with the training of the Neural Network. iv Contents 1 Introduction 1 1.1 Motivation . .1 1.2 Research Question . .2 1.3 Limitations of Learning Capability . .2 1.4 Structure of Thesis . .3 2 Prerequisites 4 2.1 Artificial Neural Networks . .4 2.2 Convolutional Neural Networks . .7 3 Literature Survey9 3.1 Scope . .9 3.2 Intuitive Interpretability . 10 3.3 Taxonomy Features . 10 3.4 Visualization of Feature Representation . 11 3.5 Visualization of Activation Attribution . 11 3.5.1 Code Inversion . 12 3.5.2 Occlusion Sensitivity . 16 3.6 Visualization of Learned Class-Concepts . 19 3.6.1 Optimisation . 19 3.7 Classification of Methods . 21 4 Experiments 23 4.1 Methodology . 23 4.2 Experimental Testbed . 24 4.3 Implementation of Debugging Methods . 25 5 Results 27 6 Summary and Future Work 30 (Listings) . 31 Bibliography . 31 (List of Figures) . 35 (List of Tables) . 36 A Appendix 37 A.1 Announcement . 37 A.2 Visualizations of ‘Unknown’ Classes . 39 v 1 Introduction The present Introduction chapter determines the frame for the thesis by naming the motivation for it and the question to investigate. First, the problem of lacking comprehension regarding Artificial Neural Networks is contemplated within section 1.1. After that, the research question of this work is defined in the next section 1.2. The third section 1.3 then points out the limitations of a Neural Network’s learning capability. Finally, the last section 1.4 describes the structure of the remaining thesis. 1.1 Motivation The field of Artificial Intelligence (AI) consists of a variety of distinct problem solving methods. Its several subfields aim at providing support in different matters and have already succeeded in doing so in areas like computer vision and natural language processing. Voice recognition and machine translation are examples of narrow tasks which, atleast for some languages, AI systems are able to carry out on human-level [RN03]. Although such systems are present in many modern devices, AI applications are still often perceived as little more than toys. Additionally, classifiers such as Neural Networks have frequently been referred to as incomprehensible black boxes due to the fact that they independently find structures in the processed material. The increasing application of AI technology makes it necessary to improve the understanding of it. Artificial Neural Networks (ANNs) as a branch of Artificial Intelligence have been on researchers’ and pundits’ minds for