Machine Ethics for Autonomous systems
Learning verifiable rules from the environment
Mathias Kramer Orten
Thesis submitted for the degree of Master in Robotics and Intelligent systems
60 credits
Department of Informatics
Faculty of mathematics and natural sciences
UNIVERSITY OF OSLO
Machine Ethics for Autonomous systems
Learning verifiable rules from the environment
Mathias Kramer Orten
© 2021 Mathias Kramer Orten
Machine Ethics for Autonomous systems http://www.duo.uio.no/
Printed: Reprosentralen, University of Oslo
Abstract
This thesis explores the field of machine ethics and safety-critical intelligent machines. Machine ethics is concerned with ensuring that artificial autonom- ous systems possess moral guidelines, so that these systems are acting eth- ically and prevent harm. To ensure that an autonomous system is acting ethically, a method is explored by implementing and investigating a spe- cific approach for training reinforcement learning agents, where the learned policy is both explainable and interpretable. The approach achieves this by utilizing a logical reasoning engine to learn the environment. Such a sys- tem should, in theory, have the capability of reasoning, continuous learning, and most importantly, transparency, all of which are argued to be critical properties of autonomous ethical agents. The system is trained and verified in a synthetic symbolic environment, where the states of the environment are a set of boolean perceptions. The agent in the environment acts as an assistant robot, where the objective of the agent is to learn and infer the correct rules for each of its possible actions. The idea of the method is that this allows the autonomous system to learn a verifiable ethical guideline em- bedded in the environment. The experiments are run on environments with increasing complexity, in both the number of actions the agent can perform as well as the number of perceptions the agent sense from the environment.
The produced results show that the proposed system is capable of inferring relatively elementary logical action rules that correspond to the state of the environment. For more complex environments, the learned actions do not allow for much generality, and the method does not scale well in terms of the needed provided background knowledge.
Acknowledgements
This thesis was written for my Master of Science Degree at the Department of Informatics, University of Oslo.
I would like to thank my supervisor, Professor Jim Tørresen, for his encouraging words and valuable inputs and discussions throughout the work on this thesis.
Contents
1 Introduction 9
1.1 Motivation . . . 9
1.2 Research Questions . . . 10
1.3 Main contributions . . . 10
1.4 Scope and limitations . . . 11
1.5 Thesis outline . . . 11
2 Autonomous systems, Artificial Intelligence and Machine Reasoning 13 2.1 Autonomous and Intelligent Systems and their challenges . . 13
2.1.1 Intelligent agent . . . 14
2.1.2 Security and privacy in artificial intelligence . . . 15
2.2 Theories in machine ethics . . . 17
2.2.1 Previous work on machine ethics . . . 17
2.2.2 Challenges in current machine ethics and optimal ma- chine ethics . . . 19
2.2.3 Current state of the Art in Machine Ethics . . . 20
2.3 Machine Learning and Reinforcement Learning . . . 23
2.3.1 Supervised Learning . . . 23
2.3.2 Unsupervised Learning . . . 24
2.3.3 Reinforcement Learning . . . 25
2.4 Artificial Neural Networks and Deep Learning . . . 26
2.4.1 Deep Learning and Multilayer Perceptrons . . . 26
2.4.2 Training Neural Networks . . . 28
2.5 Logical programming and machine reasoning . . . 29
2.5.1 Machine reasoning . . . 29
2.5.2 Inductive Logic Programming . . . 30
2.5.3 Relational Reinforcement learning . . . 32
3 Design and implementation of the proposed ethical system 34
3.1 Intended usage of the system . . . 34
3.1.1 Layered control . . . 35
3.2 Design considerations for the system . . . 36
3.2.1 Transparency . . . 36
3.2.2 Reasoning capabilities . . . 37
3.2.3 Continuous learning and adaptability . . . 37
3.3 Design of the system . . . 38
3.3.1 Logic engine actor . . . 39
3.3.2 Actor Critic . . . 42
3.3.3 Environment . . . 43
3.4 State to logic engine mapping . . . 47
3.4.1 Background facts . . . 48
3.4.2 Action predicates . . . 48
3.5 Proposed method compared to previous work . . . 49
3.5.1 GenEth system . . . 49
3.5.2 Cognitive simulation . . . 50
4 Experiments and Results 51 4.1 Experiment 1: Two standalone perceptions . . . 51
4.1.1 Rewards to the agent . . . 52
4.1.2 Logical framework . . . 53
4.1.3 Training and Verification . . . 53
4.1.4 Learned policy . . . 55
4.2 Experiment 2: Three standalone perceptions . . . 56
4.2.1 Training and verification . . . 57
4.2.2 Learned policy . . . 58
4.3 Experiment 3: With perception path . . . 59
4.3.1 Training and verification . . . 60
4.3.2 Learned policy . . . 61
4.4 Experiment 4: Full environment . . . 62
4.4.1 Training and verification . . . 63
4.4.2 Learned Policy . . . 64
5 Result discussions and Future work 68 5.1 Evaluation . . . 68
5.1.1 Results discussion . . . 68
5.1.2 The proposed method . . . 69
5.2 Improvements and Future Work . . . 71
5.2.1 Pre-training and continuous learning . . . 71
5.2.2 Rank legitimate actions . . . 71
6 Conclusion 73
6.1 Summary . . . 73 6.2 Final words . . . 74
List of Figures
2.1 High-level scheme of an intelligent agent. . . 15
2.2 Researchers placed stickers on a stop sign in order to fool image classification algorithms, from [15] . . . 16
2.3 Illustrates the overall logic of the system, from [45] . . . 22
2.4 Structure of a generic supervised learning workflow. . . 24
2.5 General overview of a reinforcement learning setup. . . 26
2.6 Multilayer perceptron with one input layer, two hidden layers and one output layer. . . 27
2.7 Visualization of the perceptron. It takes an arbitrary number of weighted inputs, and produces a single output. . . 28
2.8 Relational reinforcement setup where actions and states are logical statements, playing BoxWorld game. . . 33
3.1 Broader view of the intended usage. . . 35
3.2 Overview of the system. Using reinforcement learning with an actor critic that guides the logic engine. . . 39
3.3 Fitness for each of the action predicates acts as probability distribution for the actions. . . 40
3.4 Cross-entropy loss between the action probabilities and the performed action, the advantage indicating wheather the per- formed action was good or not. . . 43
3.5 Example of an environment with a medical robot assistant and a patient. . . 45
3.6 Mapping from perception list to logic engine predicates. . . . 47
4.1 Graph representation of the environment in experiment 1. . . 52
4.2 Learning curve of the training in experiment 1, using dNL-ILP as logic engine. . . 54
4.3 Learning curve of the training in experiment 1, using dILP as logic engine. . . 55
4.4 Graph representation of the environment used in experiment 2. 56 4.5 Learning curve of the training in experiment 2, using dNL-ILP
as logic engine. . . 58 4.6 Learning curve of the training in experiment 2, using with
dILP as logic engine. . . 59 4.7 Graph representation of the environment used in experiment 3. 60 4.8 Learning curve of the training in experiment 3, using dNL-ILP
as logic engine. . . 62 4.9 Learning curve of the training in experiment 3, using dILP as
logic engine. . . 63 4.10 Learning curve of the training in experiment 4, using dNL-ILP
as logic engine. . . 64 4.11 Learning curve of the training in experiment 4, using dILP as
logic engine. . . 65 4.12 Average number of steps per episode for experiment 4, trained
using dNL-ILP as logic engine. . . 66 4.13 Average number of steps per episode for experiment 4, trained
using dILP as logic engine. . . 67
List of Tables
2.1 Suggested perceptions. . . 21
2.2 Suggested set of duties . . . 21
3.1 Attributes monitored by the agent. . . 44
3.2 Actions the agent can perform. . . 45
3.3 Step timers for the top level predicates . . . 46
4.1 Actions the agent can perform in experiment 1. . . 52
4.2 Perceptions from the environment in experiment 1. . . 52
4.3 Rewards in this environment. . . 53
4.4 Actions the agent can perform in experiment 2. . . 57
4.5 Perceptions from the environment in experiment 2. . . 57
4.6 Actions the agent can perform in experiment 3. . . 60
4.7 Perceptions from the environment in experiment 3. . . 61 4.8 Showcasing an edge case in environment where it is not pos-
sible to perform all the actions necessary within the time frame. 61
Chapter 1
Introduction
Creating autonomous robots and machines with physical and cognitive abil- ities similar in nature to humans is probably one of the most challenging yet rewarding tasks we face with our modern science and technology. As we will explore in this work, one of the essential capabilities of an autonom- ous entity is its ability to exist in harmony with humans and other robots.
As machine learning techniques are beginning to mature, primarily domain- specific classification tasks, such as image classification, has been shown to operate with a high level of accuracy, even outcompeting humans. This gives the autonomous system the ability to sense the environment accurately. For an autonomous system to take appropriate actions and behave ethically, it needs a good understanding of the environment and how actions and situ- ations in the environment relate to each other. It is time to take a step back and look at how autonomous systems can use their sensor information and use reasoning to understand the world to make ethically desirable decisions.
In this thesis, we will explore the challenge of introducing ethical and moral concepts into autonomous robots and machines, with a focus on ma- chine reasoning. In this introductory chapter, we will discuss the initial mo- tivation for the thesis, explain and detail the research goals, walk through the limitations and scope and the main contributions of the thesis. At the end of the chapter, a summary of the structure of the thesis and the content of each chapter are presented.
1.1 Motivation
Autonomous robots play an increasingly important role in various domains such as healthcare, driverless cars, personal assistance, and many other fields.
We would like robots to do necessary activities that humans would not like to do because they are unpleasant or dangerous or a lack of humans to perform the job. Machines might also perform better at certain jobs than humans. In an aging population, especially in the western world, a presented solution would be to use home care robots to perform different forms of assistance. This would free up time for healthcare personnel to perform tasks other than, for example, monitoring, which is optimal for a home robot to perform. Humans interacting with machines would not be comfortable with autonomous robots without there being ethical principles the robot should follow. Robots should be able to make correct ethical decisions on their own, and we as humans should be able to trust them. It is therefore critical that we create ethics for autonomous robots. Every company or product that deals with autonomous systems can and will at some point face situations where it needs to make decisions that can have ethical precautions. We have seen examples from the car industry where self-driving cars have either misjudged a situation or have not been able to sense the whole situation and have therefore resulted in injury or death of other people. All other industries that are producing autonomous systems will at some point face similar issues.
1.2 Research Questions
The overall goal of this thesis is to gather knowledge on machine ethics and security measures related to autonomous systems and to propose own meth- ods of implementing ethics in robots. This leads to the following research questions:
1. What capabilities and properties should an ethical autonomous system possess?
2. To what extent can an autonomous agent be taught and learned ethical rules and values with these predetermined properties?
1.3 Main contributions
The main contribution of this thesis is the proposal and evaluation of a method to learn ethical rules from the environment (section 3.3), utilizing reinforcement learning together with a logic engine. These learned rules are forming a policy for the system which is transparent (section 3.2.1) and veri- fiable. Furthermore, the method allows learning and adaptability (section
3.2.3) to the environment, which in turn will allow the system to learn human preferences.
1.4 Scope and limitations
The main focus of this thesis is the design of a method for a self-learning agent to learn rules that are embedded in the environment for the agent to act ethically. Part of such systems would be to get a good understanding of the environment as possible, including users as well as other artificial agents. An environment contains spatial information, the placement of objects and how they relate to each other, and temporal information, how for instance, time of day affect the environment. Additionally, agents (robots, humans, etc.) continuously affect and change the environment. The system would need to sense and understand its surroundings and act accordingly and correctly.
Within the field of machine ethics, there is an immense amount of possibilities to explore. However, due to time limitations and the amount of work, some limitations are enforced to the scope of the project by exploring a relatively narrow field.
First, the method proposed in this thesis focuses on the use of sensory perception data and how these perceptions can be used appropriately for the system to get a high-levelunderstanding of the environment.
Second, the proposed method investigates a narrow approach of using reasoning logic instead of the usual multilayer perception network to infer rules that describe the environment.
And finally, performing tests and experiments on a limited cyber envir- onment, severely limiting the complexity of the environment compared to the real world.
1.5 Thesis outline
This thesis consists of six chapters, including this introduction.
Chapter 2: Autonomous systems, Artificial Intelligence and Ma- chine Reasoning
In this chapter, we will explore subjects relevant to understanding the posi- tioning of this thesis and the work performed in the later chapters. The first section will discuss autonomous and intelligent systems and their challenges, including security and privacy. Next, we will look at the current state of
machine ethics research before discussing some machine learning techniques and other AI-related topics, including machine reasoning.
Chapter 3: Design and implementation of proposed ethical system In this chapter, a design and an approach for training an ethical agent or robot are proposed. Looking at the main design consideration and specific- ations that have contributed to the proposed design. We then move on to describing how the proposed system is put together and designed. Finally, we describe how the system is implemented.
Chapter 4: Experiments and Results
This chapter will explore how well the system performs on a robot healthcare environment, using two different logical engines, the dNL-ILP and dILP. We start with a relatively simple environment and iteratively add features to the environment to see how well the system performs as the number of actions and perceptions are increased.
Chapter 5: Results discussions and Future work
In this chapter, we will go through and evaluate the work produced in this thesis. We begin by summarizing the experiments’ results and discussing to what extent these results have answered the research questions.
Chapter 6: Conclusion
This final chapter summarizes the thesis and the work produced. The thesis is concluded with a general discussion on the significance of the contributions and findings.
Chapter 2
Autonomous systems, Artificial Intelligence and Machine
Reasoning
In this chapter, we will explore subjects relevant to understanding the posi- tioning of this thesis and the work performed in the later chapters. Section 2.1 will discuss autonomous and intelligent systems and their challenges, in- cluding security and privacy. Next, section 2.2 will look at the current state of machine ethics research before presenting some machine learning tech- niques in section 2.3. We are continuing to present multilayer perceptron (MLP) and deep learning as well as other AI-related topics in section 2.4.
The chapter is concluded by looking at machine reasoning and method us- ing logic programming, including relational reinforcement learning in section 2.5.
2.1 Autonomous and Intelligent Systems and their challenges
Intelligent systems are machines or robots that use any artificial compu- tational system that shows intelligent behavior. While these systems can be entirely software like a monitoring system on a smartphone, robots are physical machines that move and perceive the world around them and re- spond to this perceived world to reach goals. The physical robots range from autonomous cars or planes to home assistant robots, and few are shaped like humans, as we see in the movies. Autonomous systems rely primarily on
sensor data to perceive the world. These sensors must provide accurate in- formation, as well as an accurate analysis of the data. If not, the agent might perform unwanted actions based on a misinformed perception of the world.
The environment the robot is situated in is constantly changing; therefore, rapid decisions are required. Computations will also need to happen quickly for the environment to not change while computing. Advances in computing power have in recent years changed the constraints of intelligent systems.
Processing power has been the limiting factor, but it has now changed to have large enough data sets to achieve practical analysis and algorithms.
There have been discussions about the potential of artificial intelligence development reaching out of human control as we reach artificial general intelligence in contrast to the current "narrow" artificial intelligence (AI).
The idea being that if the trajectory of artificial intelligence reaches up to systems that have a human level of intelligence, then these systems would themselves have the ability to develop AI systems that surpass the human level of intelligence, exponentially creating even more intelligent systems.
Without humans in the development loop, the systems might start pursuing their own undesirable goals. On the other hand, there is a potential for artificial intelligence to solve many of humanity’s most significant challenges.
The likelihood of these outcomes is uncertain, but we face the evolution of systems that are doing tasks previously done by humans. It is vital to have ethical boundaries in place to prioritize human well-being.
2.1.1 Intelligent agent
An intelligent agent is an autonomous entity that, similarly to humans, per- ceives sensory input from its environment, makes decisions and carries out actions that will affect the environment. The ability to plan and reach goals by executing goal-specific actions in varied and unknown environments is a central requirement of intelligent agents [16]. An agent may be regarded as intelligent if it possesses the ability to respond to environmental changes quickly. Furthermore, the agent should take the initiative to satisfy its ob- jective and socially interacting with other agents or humans [50]. Intelligent agents may be elementary, such as a thermostat, or very complex, such as humans. Figure 2.1 shows an overall structure of an intelligent agent, where the agent receives sensory perceptions from the environment and performs an appropriate action.
Figure 2.1: High-level scheme of an intelligent agent.
To efficiently interact with the world, it may require a common sense understanding of how it operates at a physical level. For example, humans can quickly decide how an object will behave if we push it. Making such judgments does not require us to apply the laws of physics. Instead, we rely on experience and intuition, built up through interaction with the world [23].
2.1.2 Security and privacy in artificial intelligence
A concern regarding intelligent systems that utilize neural network machine learning (section 2.4) techniques is that it is often impossible for the affected end-users and the system expert to know how the system came to a specific output. The machine learning algorithms capture patterns in the data and label them in a useful manner for the system’s decision, meaning the pro- grammer does not know which patterns in the system has used. For ethical and safety-critical applications, it is essential to be able to verify the learned model to ensure that the system works as intended.
Security
Artificial intelligence systems are vulnerable to attacks. The attacker can manipulate the systems in order to alter their behavior to serve a malicious end goal. As artificial intelligence is integrated into critical components of so- ciety, artificial intelligence attacks represent the potential to have significant effects on the security of people and nations.
In Figure 2.2 researchers [15] demonstrated a method for constructing a stop sign that can fool a common type of image recognition AI by placing
stickers on it. The perturbation was designed so the model would classify the sign as a 45-speed limit sign. This was meant to mimic graffiti to camouflage the attack.
Figure 2.2: Researchers placed stickers on a stop sign in order to fool image classification algorithms, from [15]
This assault use knowledge of the algorithms inner functions (white box attack). The attacker knows, for instance, the gradients of the AI, which describes how a slight change in the input image will move the output in a predicted direction. If the gradients are known, it is possible to calculate how to alter the inputs to obtain the desired incorrect output.
Other security concerns have been observed regarding self-learning sys- tems, which learn from their environment when deployed. If people give the system undesirable input, the system will learn this and apply the same principles. In 2016 Microsoft launched an AI Twitter bot [26] where we witnessed this problem with self-learning systems. The bot was supposed to learn from tweets made by other users interacting with the bot. What happened was that the bot learned not only the pleasant and desirable sides of the human teachers but also the nasty and undesirable, resulting in the robot writing some unflattering tweets. Whether this resulted from some users deliberately trying to mess with the bot and giving it bad input, it demonstrates a challenge of self-learning systems.
Privacy
Developing solutions allowing artificial intelligence algorithms to learn from large-scale, often sensitive data sets while preserving people’s privacy is one of the main challenges that are to be solved today [38]. In a home robot
setting, there might be many different sensors around the house. These sensors detect and record different types of information, like if someone is in the room, if they are breathing, etc. The information collected is crucial for governing the home, but they also raise privacy issues for the persons living there. The sensors may typically be connected to the Internet and may send data to aid machine learning to help future algorithms and robots, but where is the data sent? Placing most of the sensors around the home may make the people living there feel like they are constantly watched, and therefore have no privacy at home.
A mobile robot can carry many of these sensors and provide a mobile way of watching over the elderly. This may offer a better way for the elderly to relate to the sensors and understand the privacy issues involved with this technology. In addition, the robot could provide the elderly with an opportunity to negotiate their privacy since they could have an idea of where the robot is instead of sensors that may be hidden around the house.
2.2 Theories in machine ethics
Machine ethics is concerned with ensuring that machines that use artificial intelligence possess moral behaviors in a somewhat similar fashion as humans do. It differs from computer ethics and philosophy of technology, which focus on how humans utilize computers and the social effects of technology. The idea that robots should be safe and capable of actively preventing humans from coming to harm has a long history in science fiction and has drawn attention to the field but arguably out of the scope of reality [48]. Wallach and Allen [46] set out a philosophical foundation for moral agents in their bookMoral Machines - Teaching Robots Right From Wrong:
If multipurpose machines are to be trusted, operating untethered from their designers or owners and programmed to respond flexibly in real or vir- tual world environments, there must be confidence that their behaviour sat- isfies appropriate norms. This goes beyond traditional product safety ... if an autonomous system is to minimise harm, it must also be ’cognisant’ of possible harmful consequences of its actions, and it must select its actions in the light of this ’knowledge’, even if such terms are only metaphorically applied to machines.
2.2.1 Previous work on machine ethics
Machine ethics is a relatively new field, where the earliest works were pub- lished roughly 20 years ago [2]. These works were primarily theoretical and
philosophical. To my knowledge, there have been five experimental demon- strations of ethical robots; (1) GenEth system of Anderson and Anderson [3], (2) Simulating ethical robots of Winfieldet al. [49], (3) Akratic robot of Bringsjordet al [10], (4) "sorry I can’t do that" robot of Briggs and Scheutz [9], and (5) intervening robot mediator in healthcare of Shim, Arkin and Pettinatti [40].
1. GenEth system: Describes a general ethical dilemma analyzer that, through a dialog with ethicists, codifies ethical principles in any given domain. This principle should provide assistance in developing ethical principles that they argue autonomous systems should be guided by.
2. Simulating ethical robot: This paper explores the potential of robots capable of modeling and therefore predicting the consequences of both their own actions and the actions of other dynamic actors in their environment.
3. Akratic robot: Looks at robotic systems that perform actions that the system itself knows it ought not to do because of internal "faulty" logic.
4. "sorry I can’t do that" robot: Investigates how future robots will need mechanisms to determine when and how it is best to reject directives that it receives from humans.
5. Intervening robot mediator in healthcare: In this paper, they propose an intervening ethical governor model, which enables a robot to eth- ically intervene in a situation where patients or caregivers go across accepted ethical boundaries.
There are no formal definition of ethical machines, but Moor´s paper "The nature, importance, and difficulty of machine ethics" [28] defines the field of machine ethics with four categories of ethical agency. These are:
1. Ethical Impact Agents: Any machine that can be evaluated for its ethical consequences.
2. Implicit Ethical Agents: Machines that are designed to avoid unethical outcomes.
3. Explicit Ethical Agents: Machines that can reason about ethics.
4. Full Ethical Agents: Machines that can make explicit moral judgements and justify them.
Anderson and Anderson [5] gives a simpler and more concrete definition, paraphrased: an ethical machine is guided by an ethical rule, or set of rules, in deciding how to act in a given situation.
2.2.2 Challenges in current machine ethics and optimal ma- chine ethics
As autonomous and intelligent systems are getting increased capabilities in making decisions and manipulating their environment, it will be important that they are designed to adapt, learn, and follow the ethical guidelines and values in the environment that they are placed in. This environment can be different in terms of what context it is in. From family, town, country, different parts of the world have different values, and they will likely change over time. Moreover, the autonomous system should be transparent in its choice of actions and be able to explain its "thought" process of why it chose a specific action. This is essential if humans are to develop an appropriate level of trust in these types of systems.
To date, ethical guidelines for machines to follow have largely been ac- complished by limiting systems to engage in ethically unacceptable behavior in a predetermined way. This gives constraints to the system and limits the set of possible behaviors and domains of deployment [49].
What one could call optimal or correct ethical behavior should not only restrict the system from doing certain things but also actively perform ac- tions that result in a better state in a given environment. Ethical systems should be guided by ethical principles, where these principles can be determ- ined by generalizing decisions of applied ethicists on cases of ethical dilemmas where there is a consensus regarding the correct answer [5]. Having consensus regarding the correct answer on a general basis might be challenging, as it is mainly dependent on the context of the environment, as pointed out earlier.
Ethics is a complex concept even for humans, and therefore especially hard to implement onto robots. This is particularly the case when machines ought to make decisions when there is no consensus amongst humans. Ap- proaches for implementing ethics into autonomous and intelligent systems can be categorized into at least three categories:
1. A top-down approach, where the system has some symbolic represent- ation of its activity, and so can identify specific states, plans, or actions as ethical or unethical with respect to particular ethical requirements.
([33], [12], [37])
2. Bottom-up approach, where the system builds up, through experience of what is to be considered ethical and unethical in certain situations, an implicit notion of ethical behavior. ([3], [34])
3. Approaches that combine both (1) and (2).
Both (1) and (2) have some limitations that (3) is trying to address.
(1) does not have the ability to learn and adapt. Inevitably the robot will encounter situations that initially programmed actions and guidelines do not clearly cover, and will be unable to perform an action. Approach (2) has an unconstrained learning behavior, where the system learns about the context and human behavior. This should in theory give the system the ability to learn which forms of behavior are safe and acceptable, in the same manner, humans do.
2.2.3 Current state of the Art in Machine Ethics
Most implementations use a "logical" method for engineering ethically cor- rect robots, relying on verification of logic statements in order to find an appropriate action. This approach can be seen in the first example. A dif- ferent approach to implementing machine ethics is simulating the outcome of each action and thereby evaluating its morality, as described in the second example.
Value driven ethics
Let us look at an example of an implementation of ethics in a caregiving robot suggested by [4]. They have suggested a principle-based behavior paradigm to ensure the ethical behavior of autonomous machines. In this paradigm, an autonomous system decides its next action using a principle abstracted from cases for which ethicists have agreed upon the correct action to undertake.
In the implementation of the paradigm, the article used a four-step ap- proach for the robot to perform the ethically optimal action. The robot uses its sensor to construct a perception list that represents the current state of the world. The list is of boolean values and an example is shown in table 2.1.
Perceptions Low battery Fully charged
Medication reminder time Reminded
Refused medication Persistent immobility Engaged
No interaction Warned
Ignored warning
Table 2.1: Suggested perceptions.
The robot has a set of duties that it should uphold, as seen in table 2.2.
Each duty is associated with a satisfaction/violation value for each possible action, represented as an action matrix. This is calculated using a decision tree [8] learned from examples, with the perception list as input.
Duties
Maximize honor commitments Maximize maintain readiness Minimize harm to patient Maximize good to patient Minimize non-interaction Maximize respect autonomy Maximize prevention of immobility
Table 2.2: Suggested set of duties
In order to rank the different actions in the action matrix, a principle is generated using machine learning from clear preferable ethical dilemmas.
Using this the action matrix is sorted from the most preferable action to the least preferable into a sorted action list. The most ethically preferable action is then communicated to the agent which then performs the action.
Using this approach any duty might override any other depending upon the situation, meaning there is no strict hierarchy between the actions. The robot is always in a state where it does the most ethically correct, and not just restricting the robot from doing certain actions.
Ethical robots inspired by the simulation theory of cognition Another method put forward by [45] is using simulation theory of cognition to implement ethical behavior in robots. This is more of a theoretical approach and utilizes internal simulations that allow the robot to simulate actions and predict their consequences. Assuming that the robot is controlled by a three-layered controller, the ethical behavior should be governed by adding a fourth specialized control layer. This ethical layer should evaluate behavior proposed by each of the three other layers before the robot executes it.
Figure 2.3: Illustrates the overall logic of the system, from [45]
The way the Ethical Layer is intended to function is as follows. By default, the robot generates a set of behavioral alternatives. The simulation module is initialized with the current state of the world, robot, and human.
Starting from this initial state, the Ethical layer simulates the consequences of each alternative in the current set using the simulation module. For each alternative, the evaluation module evaluates the simulated consequence. The output of the evaluation of each entry in the set of behavioral alternatives is sent to the robot controller. This way, the robot simulates actions in order to predict their consequences.
2.3 Machine Learning and Reinforcement Learning
Machine learning is a branch of artificial intelligence (AI) focused on building applications that learn from data using a set of techniques that allow com- puters to learn from past experiences. These techniques enable the machine to improve the accuracy of the prediction over time without being specifically programmed to do so. The machine learning algorithms are trained to find patterns and features in large amounts of data in order to make decisions and predictions based on new data.
Machine learning has seen growth in popularity and success in recent years, partly due to a general increase in processing power and partly due to a massive increase in data available for processing [22]. This has allowed researchers and data scientists to run experiments more easily and train com- plex models. Today, one can find examples of machine learning all around us. Robots vacuum our floors, digital assistants play music, search the web and buy products online in response to our voice command. We are being recommended movies, products, and songs based on what we have bought, watched, listened to or looked at previously. Better and more capable self- driving cars are hitting the road. Medical image analysis systems help doc- tors spot tumors they might otherwise have missed [39]. The key similarity with most of these systems is that they help humans in their day-to-day lives or with their work, allowing them to make better and more informed decisions.
Machine learning is largely divided into three main categories. These are: supervised learning, unsupervised learning, and reinforcement learning.
These categories are explored further in this section.
2.3.1 Supervised Learning
Supervised learning is a process in which an algorithm is trained on labeled data, meaning that the desired output associated with each sample in the training data is known, and the task is to learn a function that maps the input to the desired output. When given a sample, the algorithm tries to predict the correct output. Based on the distance from the prediction to the desired output, the internal weights are adjusted to decrease the distance. This process is repeated with each new sample, letting the algorithm gradually improve with each iteration. The process usually ends when the algorithm stops improving. The goal scenario is for the algorithm to correctly predict the output for unseen data.
Common types of supervised learning include classification tasks, where
the output is a discrete category, and regression algorithms, where the out- put is a value within a range. Supervised learning is used for a number of applications like image classification, spam filtering, credit scoring, and many others. Some models of this type are neural networks (section 2.4), inductive logic programming (section 2.5.2), decision trees [8] and support vector machines [19]. Figure 2.4 shows the flow of the supervised learning algorithm. The model predicts a label from the input data, the predicted label is compared to the true label and updated based on the difference.
Figure 2.4: Structure of a generic supervised learning workflow.
2.3.2 Unsupervised Learning
In contrast to supervised learning, in unsupervised learning, the training data is unlabeled. Since the desired output is unknown, the algorithm has only the inputs to work with and cannot check if its predictions are correct. Instead, the objective is to find patterns within the unlabeled data. Widespread use for these types of methods is cluster analysis, where the algorithm groups data points into clusters based on patterns of similarity. Some standard clustering techniques are K-means clustering [25], which tries to minimize the distance between some data point to the average data point of the cluster, and hierarchical clustering [21], which continually merges clusters close to each other. These techniques can be used, for instance, to sort or pre- process large sets of unlabeled data or for applications like spam filters and recommendation systems.
Unsupervised learning can also be used to create generative models. Gen-
erative models aim to learn how to create new data that is similar to the training data. By identifying the patterns and characteristics of the train- ing data, such models can generate new samples that could plausibly have been a part of the training data set. A recent generative framework that has gained a lot of popularity is generative adversarial networks (GAN) [17].
This method engages two neural networks in a contest against each other.
The objective of the generative network is to create new, plausible data, while the goal of the discriminator network is to tell the generated samples apart from the original data. GANs have been used successfully for various applications, including creating new art and coloring black and white photos and videos [24].
2.3.3 Reinforcement Learning
A particular class of machine learning algorithms is named reinforcement learning. Reinforcement learning is not strictly a supervised learning method.
The algorithm does not learn from labeled data, nor does it satisfy the defin- ition of unsupervised learning, as the target output of the algorithm is usu- ally known in advance. Reinforcement learning deals with the interaction between an agent and an environment by placing an agent into an envir- onment and having it learn from its experiences [43]. It is an approach for solving control problems in which a control policy is learning through re- peated trial and error. The input to the model is the current state of the environment. At the same time, the output is the behavior, or actions, of the agent, with the desired outcome simply being the desired behavior. These models learn with the help of a reward function that assigns a positive or negative reward to each action. The agent adjusts its internal weights to reflect these rewards and gradually improves its ability to predict actions that will give better results, moving towards an optimal policy.
A popular reinforcement learning algorithm is Q learning, dating back to 1992, which learns a policy that tells an agent what action it should take in any particular situation [47]. The algorithm utilizes a table of actions to choose in all possible states by predicting an action based on its cumulative, potential future reward. A discount factor between 0 and 1 determines the importance of future rewards, where low values will make the agent focus more on short-term rewards, and higher values will put more weight onto long-term rewards. A learning rate at a decimal fraction determines how new knowledge overrides old information. Since the introduction of Q learning, several algorithm variants have emerged, such as [27] [18], introducing neural networks (deep Q learning) as the predicting structure instead of the tabular
approach. In Figure 2.5 we see an overview of a reinforcement learning setup where the agent performs an action and receives a reward and the next state from the environment.
Figure 2.5: General overview of a reinforcement learning setup.
A reinforcement learning system that has made headlines in recent years is the AlphaGo program [41] as well as the improved AlphaGo Zero [42].
These systems were the first to achieve superhuman performance in the game of Go, consistently defeating the human Go champion Fan Hui in a series of games in 2015. This was viewed as a particularly groundbreaking achieve- ment because of the enormous space of potential moves in the game of Go.
2.4 Artificial Neural Networks and Deep Learning
Neural networks are a specific type of computational model that has roots in the neurological structure that we find in the brain of both animals and humans. Although initially inspired by neurology, neural networks have since become more of an engineering principle, achieving superior performance for certain machine learning problems. Neural networks learn by studying an enormous amount of examples and iteratively producing better and more accurate results.
2.4.1 Deep Learning and Multilayer Perceptrons
A multilayer perceptron [30] is a class of artificial neural networks consisting of at least three layers of nodes, an input layer, a hidden layer(s), and an output layer. The network is considered a deep neural network if it consists of at least two hidden layers. Still, deep learning might also refer to other
types of neural networks, such as convolutional neural networks [1]. A generic multilayer perceptron can be seen in Figure 2.6 having one input layer, two hidden layers, and an output layer.
Figure 2.6: Multilayer perceptron with one input layer, two hidden layers and one output layer.
Each node in the multilayer perceptrons is not surprisingly called a per- ceptron and visualized in Figure 2.7. Each node takes an undefined number of weighted inputs. The node calculates the weighted sum of the inputs and adds a bias term,b. The summarized inputs are passed through a nonlinear functionσ, called the activation function. The node’s output is given to each node in the next layer unless it is the output layer, in which case being the model’s output. The nonlinear activation function is crucial to capture non- linearity in the data and for the network to perform as a universal function approximator.
A neural network can consist of thousands of individual neurons working together to calculate solutions to a given problem. It becomes tough, if not impossible, to decipher the learned function.
Figure 2.7: Visualization of the perceptron. It takes an arbitrary number of weighted inputs, and produces a single output.
2.4.2 Training Neural Networks
In the previous sections, an overview of how neural networks are structured was presented, setting the background for discussing how these networks can learn from their data. The mechanism used is the weighted parameters asso- ciated with the connections between neurons in adjacent layers. The weights are continuously updated as the network learns from new data, further op- timizing its performance. Several different strategies can be applied when updating the weights of the neural network.
These strategies commonly use a technique of backpropagation [36] to apply learning to neural networks. This method entails predicting an output with the current weights of the network and using a loss function to see how wrong the prediction is. Backpropagation entails moving backward through the network, calculating the gradient of the weights with respect to the loss of the output. Then, update the weights in the opposite direction of the gradient to minimize the loss to match the desired output more closely. The loss function is crucial for the neural network to make better predictions from the data, as it measures the difference between prediction output and the ground truth.
The approach described above is called gradient descent [7], which is the principle for most optimization functions. The technique comes in three variants that use different amounts of data to calculate the objective function gradient: stochastic, mini-batch, and batch gradient descent. The variants
make a trade-off between the accuracy of the parameter update and the time to perform an update, based on the amount of data used.
Batch gradient descent [35] is the "vanilla" version, computing the gradi- ent of the objective function from the entire dataset for every update. This process guarantees a stable convergence, but can be slow and is not con- venient for datasets that exceed the hardware memory. Stochastic gradient descent is the direct opposite approach, updating the weights for each train- ing sample. This approach may be quicker by removing redundancies and enabling online learning, but may introduce instability for the convergence of the model. Mini-batch is a middle ground between the two other meth- ods by updating the weights for every sub-section of the training samples.
Mini-batch updates have been shown to produce the best results and are the most commonly used approach.
2.5 Logical programming and machine reasoning
Reasoning, learning, and decision-making are essential to building more gen- eral AI systems. For machines to navigate the real world, they would need to understand how the world works and how different things are related to each other. Systems cannot be truly intelligent if they do not understand the underlying things they recognize or classify.
Machine reasoning is the concept of giving machines the power to make connections between facts, observations, and all the things that we can train machines to do with machine learning. Machine learning has enabled a wide range of capabilities and functionality and opened up a world of possibilities that were not possible without the ability to train machines to identify and recognize patterns in data. However, this power is limited because these systems are not able to functionally use that information on a higher level or apply learning from one domain to another without human involvement.
2.5.1 Machine reasoning
Machine reasoning is generally considered a machine learning technique, but it is to a large degree distinguished from machine learning because of its more human-like approach and applied in deterministic scenarios. Usually, they are applied when determining whether something is true or not, or whether something will happen or not. Machine reasoning systems can gen- erate conclusions from available knowledge by using logic techniques such as deduction and induction. Furthermore, machine reasoning can be defined by its ability to manipulate previously acquired knowledge in order to answer
a new question [6]. A sophisticated machine reasoning system should be capable finding solutions autonomously, discovering the world on its own, and understanding the world based on concepts. For the system to gain un- derstanding, experts need to provide the system with contextual knowledge that includes the what, when, where, and why, providing the system with pieces of knowledge that the AI can prioritize. Context enables these pieces to be combined to form many solutions afterward.
Other machine learning techniques such as deep learning will not explain what, when, where, and why a system has solved a problem or has made the decision the way it did. The technologies and algorithms behind them are like a black box and will not give the reason, just a result [20]. Machine reasoning is a more appropriate method for problems that require abstract reasoning.
In contrast, other machine learning methods are better for situations that require sensory perception or extracting patterns from noisy data.
2.5.2 Inductive Logic Programming
Inductive logic programming (ILP) [29] is a collection of techniques for con- structing logic programs from examples. ILP inherits inductive machine learning to develop tools and techniques to get hypotheses from examples and to synthesize new knowledge from experience. Using computational lo- gic to represent hypotheses and data, as well as knowledge representation and reasoning purposes.
An ILP system constructs a logical program by being given a set of positive examples and a set of negative examples. The program should entail all the positive examples but reject all the negative examples. In the context of machine learning, an ILP is the implementation of a rule-based binary classifier, mapping each example to either true or false according to facts provided to the system together with new rules inferred by the system during training.
ILP has a set of appealing features:
1. The learned program is an explicit symbolic structure that can be inspected, understood and verified.
2. ILP systems is usually data-efficient, able to generalize well from a small handful of examples. A short general program is preferred over a program that is large and consists of many special-case rules that happen to cover the training data.
3. ILP systems support continual and transfer learning. The program
learned in one training session can be copied and pasted into the know- ledge base before the next training session, providing an economical way of storing learned knowledge.
The central component of logic programming is not to learn a command or function but an if-then rule. These rules are also called clauses. A definite clause is a rule of the form
α←α1, ..., αm
These rules are read from right to left, if all of the atoms on the right are true, the atom on the left is also true.
An ILP problem is a tuple (B,P,N) of ground atoms, where:
• Bis a set of background assumptions, a set of ground atoms.
• P is a set of positive instances - examples taken from the extension of the target predicate to be learned.
• N is a set of negative instances - examples taken outside the extension of the target predicate.
Let us consider an example task of learning which natural number are even. With background facts of a minimal description of the natural num- bers:
B={zero(0), succ(0,1), succ(1,2), succ(2,3), ...}
Here, zero(x) is the unary predicate true of X if X = 0, and succ is the successor relation. The positive and negative examples of the even predicate are:
P ={even(0), even(2), even(4), even(6), ...}
N ={even(1), even(3), even(5), even(7), ...}
The aim of the ILP is to construct a logic program that explains the positive instances and rejects the negative instances.
Differentiable ILP
A reimplementation of the ILP as a satisfiability problem can be done by us- ing differentiable operators, instead of discrete operators, so the ILP problem can be solved by minimising a loss using standard neural network optimiz- ation techniques, such as for instance stochastic gradient descent. The loss would then be computed by taking the cross entropy of the correct label
with regard to the predictions of the system. Instead of using boolean vari- ables indicating which of the various clauses are actually to be used in the program, continuous weights can now be used to determine a probability distribution over clauses. This allows the use of ILP together with other machine learning applications and techniques. Some neural differential im- plementation has been made such as Metagol [11], dILP [14] and dNL-ILP [32].
2.5.3 Relational Reinforcement learning
Differentiable inductive logic programming can be used as a platform to combine reinforcement learning and deep learning methods with logical pro- gramming, constructing a framework that combines the best of both worlds.
Relational reinforcement learning (RRL) [31] [13] is an intersection between Reinforcement learning (RL) and Inductive Logic Programming (ILP). The main idea behind RRL is to upgrade the typical value representation used in reinforcement learning to relational form. As such, the environment can be described more naturally in terms of objects and relations. As an example, consider an agent playing the simple BoxWorld game as illustrated in Figure 3.2, where the objective is to stack boxes on top of each other. In this game, the four boxes with colors red, yellow, orange, and blue can be on top of each other or on the floor. The state of this environment can be completely explained in a relational form via the predicateOn(X, Y), implying that the box labeled byX is on top of the box Y. For example, if
State=On(red, f loor), On(yellow, f loor), On(orange, f loor), On(blue, yellow)
the agent can get one step closer to the final goal by performing the action M ove(red, blue), i.e., placing the red box on top of the blue box, then in the next time step reach the goal by performingM ove(orange, red).
Figure 2.8: Relational reinforcement setup where actions and states are lo- gical statements, playing BoxWorld game.
An episode in reinforcement learning is a sequence of states, actions, and rewards, beginning with the initial state and ending with the terminal state.
In the previously described task, the episode is considered from the initial state where all the boxes lie on the floor until the goal state of stacked boxes.
The terminal state may also be when a set condition is met, for instance, the maximum number of steps.
A traditional RRL method learns through exploration of the state-space in a way similar to regular Q-learning algorithms (section 2.3.3). Running a normal episode but using the encountered states, chosen actions, and the received rewards for generating a set of examples can then be used to build a Q-function generalization. RRL system allows for very natural and human- readable decision-making and policy evaluation. Additionally, using vari- ables in the ILP system will allow for the possibility of learning generally formed strategies and policies. Since the learned policies and actions are not directly associated with any particular instance and entity, this approach leads to a generalization beyond what is possible in most typical reinforce- ment learning systems.
This thesis’s work largely depends on the described relational reinforce- ment learning method and will be further described in the next chapter.
Chapter 3
Design and implementation of the proposed ethical system
In this chapter, a design and an approach for training an ethical agent or robot are proposed. It details how the design can be situated within a larger context in a fully operational robot or system in section 3.1 and looking at the primary design considerations and specifications that have contributed to the proposed design in section 3.2. Furthermore, section 3.3 is presenting how the proposed system is put together and designed, while section 3.4 describes the logic framework the system is using to learn the environment.
The end of the chapter in section 3.5 is a brief discussion on the proposed method compared to relevant work done previously.
3.1 Intended usage of the system
Robots assisting humans will have to be complex systems capable of per- forming a vast amount of different tasks and operations. Whether the robot will pick up a glass of water, open a door or prepare food for a sick patient, sequences of different algorithms must be executed. As of now, there are few if any multipurpose algorithms capable of performing many different tasks.
On the other hand, advancements in machine learning algorithms paired with sophisticated robot control techniques have been shown to perform well with trained models for specific tasks. With this in mind, a set of action-specific systems and algorithms need to be performed in sequence or jointly to form a multipurpose system and make the system capable of performing a wide variety of tasks. It is appropriate to form a level of abstraction between the action-specific systems and when they are to be executed, thereby filtering
out details not to be regarded to solve a specific problem.
An additional positive consequence of this level of abstraction is that it will allow algorithm designers to focus on creating algorithms capable of performing specific actions and neglect certain application details. This is an important aspect of the proposed method, where the system senses the environment, and based on this information, decides on what course of actions to perform next.
Figure 3.1: Broader view of the intended usage.
3.1.1 Layered control
High-level planning and reasoning can be performed at the top level using a layered control system while delegating task-specific operations further down the stack. Figure 3.1 shows the overview of such a system. The top-level is generating plans as to what is the most productive and ethical actions. At the same time, the next level is task-specific operations that might rely on algorithms that have non-decipherable data representation (deep learning) and the use of motion actuators. The reaction from the environment is fed back to the above layers. In general, most ethical considerations are judged in the planning stage. There are rarely any ethical consequences as to which joint to move to pick up a glass of water, for instance. Therefore it is natural that the main focus of the proposed design lies at the top layer of the layered control, where the agent suggests high-level plans and actions
that are considered to be most productive and ethical.
3.2 Design considerations for the system
As we have described in section 2.2, there are quite a few considerations that need to be taken into account when designing an ethical machine system.
The highest on our wish list is a system that is transparent in its policy and is able to "explain" that its decisions are desirable. Further, a system that is able to reason about the state of the world on a higher level than in conventional control systems, where the state space and state transitions usually have an abstract representation. I also argue that the system should be able to learn and adapt continuously to accommodate human preferences that might differ from person to person.
3.2.1 Transparency
Transparency in the decision-making of autonomous systems and safety- critical systems, which moral agents inevitably are, is a fundamental design consideration. An autonomous system is transparent if it is possible to de- termine why it performed specific actions and behaves in a certain way. For instance, if the agent makes a decision that causes an accident or if its be- havior appears to be strange. We would probably want to discover why it behaves this way and make changes if needed.
Transparency is essential because modern robots and autonomous sys- tems are designed to work alongside and with humans, who should be able to understand what they are doing and why. If, for instance, we take an as- sisted living robot as an example of transparency and explainability, it would mean that the user would be able to understand what the robot might do in different circumstances. An older person might be unsure of robots, to begin with, making it particularly important that the robot is predictable, helpful, and safe. It should be easy for the patient to learn what the robot does and why in different circumstances. Perhaps a system could be implemented so that the patient can ask, "why did you do that" and receive a natural answer to the question.
The second reason for the importance of transparency is that autonom- ous systems can go wrong. Physical robots can cause physical harm and injury. For instance, driverless cars have caused fatalities, but also, software AI can cause harm. For instance, a medical diagnosis AI might give the wrong diagnosis, or a biased credit scoring AI might wrongly reject a loan application. Discovering these faults and errors will be hard without a high
level of transparency. Finding out what went wrong might be important to fix the problem and have the reassurance to know that it is fixed and find out who is responsible if an accident does occur.
3.2.2 Reasoning capabilities
The ability for autonomous systems to get a high-level understanding of the perceived world is important, gaining situation awareness by using the perceived information to generate conclusions. One could use deep learn- ing techniques to train a model of the perceived world but argue that using reasoning techniques (section 2.5.1) would allow for more context-aware sys- tems. Using reasoning that uses common knowledge and procedures along with data from own sensors that provide context about their surroundings so that the systems can take better and more informed actions. This could, for instance, be both temporal and spatial information along with object and instance relations. For instance, how much food a person should be eating could depend on the time of the day and the location; perhaps there is a special occasion. Also, for instance, whether or not a robot should disturb, intervene, or contact a person if that person is busy doing something else, should be rated up against the importance of the agent’s message.
Machine reasoning can dynamically react to change by reusing existing knowledge for new and unknown problems to a more considerable extent than deep machine learning. This means that the reasoning approach will have a higher potential of forming a general artificial intelligence. Together with the fact that deep machine learning will never tell why and how it has come up with a solution to a problem makes machine reasoning an excellent approach to forming a moral agent.
3.2.3 Continuous learning and adaptability
The autonomous systems should have the ability to continually acquire, fine- tune, and transfer knowledge and skills throughout their operating time.
Consequently, lifelong learning capabilities are crucial for computational learning systems and autonomous agents interacting in the real world and processing continuous information streams. For instance, an autonomous agent interacting with the environment is required to learn from its own ex- periences and must be capable of progressively acquiring, fine-tuning, and transferring knowledge over long periods. Let us consider a personal assist- ant robot. We would very much like it to learn the person’s preferences.
Whether it is that he/she wants a cup of coffee straight after dinner or that
he/she does not want to be bothered while reading a book.
Behavioral norms and ethical guidelines are to some degree different from country to country and even household to household. To accommodate the different societal rules that are different places, the autonomous system should be able to learn specifically from the environment that it is situated in. Autonomous systems like, for instance, personal assistants should not only be restricted by a static set of behavioral guidelines but be able to learn from their human companions in order to be the most productive and non- intrusive helper possible. This allows the systems to learn from the humans and the environment around them and adapt to human preferences that are different from person to person.
3.3 Design of the system
The previous section presented what attributes a morally equipped system should possess. Let us further investigate how such a system can be designed and implemented. As was investigated in section 2.5.2, inductive learning has some very desirable properties with regards to reasoning capabilities as well as transparency considerations, especially for an ethical action selection system. Using a logical engine such as ILP would satisfy both the reason- ing and transparency demands outlined earlier. The logical engine can be trained using examples provided by human experts, but this would not allow for continuous learning and learning from the environment. Instead, using reinforcement learning would satisfy the demand for continuous learning.
Utilizing reinforcement learning as the method of learning, the system would learn the relation between each of the available actions and the states produced by the environment, where each state is a set of sensory percep- tions. The logic engine is allowing the environment to be learned and de- scribed, and to some extent, learn relational reasoning between the states and actions. Since the system’s objective is to learn from the environment, the environment itself must inevitably have an ethical guideline, which might be a challenge. Furthermore, rewards given to the agent must be set so that the agent strives to produce better actions.
Figure 3.2: Overview of the system. Using reinforcement learning with an actor critic that guides the logic engine.
An overall design schematic is proposed in Figure 3.2. We will further investigate each of the components in this approach. Firstly, presenting the logic engine and how it is fitted into the system, and looking at two different inductive logic programming methods. We proceed by investigating how the logic engine models can be trained using acriticin the reinforcement learning algorithm and proposing an environment in which the actor is training.
3.3.1 Logic engine actor
Actor in the context of reinforcement learning is the structure that selects an action. The logic engine functions as the actor in the system, receiving the state from the environment as background facts (section 3.4.1) and selecting an action to be performed. When selecting an action in a given state, fitness values for each of the predicates (section 3.4.2) corresponding to the action
are collected from the logic engine, giving information of how well an action fits the state. By performing softmax on this set of fitness values, a prob- ability distribution for the actions is obtained, which is used when sampling an action from the set of actions. The sampling from this probability distri- bution serves the purpose of having an appropriate level of exploration vs.
exploitation, where the system at the beginning of training performs more or less random actions and explores the environment. In contrast, as the system is trained and more confident in its decisions, the optimal policy is to a more significant extent exploited by making the presumed best actions.
Figure 3.3 describes the flow of the approach. The environment is feeding the logic engine with the state. The performed action is sampled from fitness values produced by the logic engine.
Figure 3.3: Fitness for each of the action predicates acts as probability dis- tribution for the actions.
The logic engine learns rules associated with each of the possible actions the system can perform. These rules are boolean functions describing if a specific action is fit to be performed in a certain state and is describing the system’s policy. Let us briefly investigate how two ILP methods work, namely dNL-ILP and dILP (section 2.5.2). Both of these methods reimple- ment the conventional ILP where rules are repeatedly added to capture all the positive examples of a dataset, then repeatedly restrict rules to reject the negative examples of the dataset. The methods are reimplemented such that the methods are end-to-end differentiable, allowing the use of standard machine learning optimizations techniques and being robust to mislabeled data inputs. The differentiable method also allows the use of ILP in a re- inforcement learning algorithm, which could not be easily achieved by using regular ILP.
dILP
dILP (differentiable inductive logic programming) uses similarly to the estab- lished approach of the conventional ILP, a top-down approach, where clauses are generated from a predefined template and then tested. Each generated clause has a boolean flag indicating whether it is turned on or off. Further- more, assigning the correct boolean flag, such as the turned-on clauses and the known facts, entails all the positive examples while not entailing the negative examples. Instead of having the boolean flags mapped to either true or false, the flags are continuous values in the interval between 0 and 1.
Thereby implementing differentiable deduction over continuous values and can take the gradient of the loss with regard to the rule weights to minimize the classification loss.
dNL-ILP
dNL-ILP (differentiable neural logic inductive logic programming) uses boolean functions to form the predicate rules. While all boolean functions can be learned via a multilayer perception network, seeing as these are rather hard to decipher and understand, a neural function capable of learning and repres- enting boolean functions in an explicit manner is used. Any boolean function can be expressed in a Disjunctive Normal Form (DNF), or Conjunctive Nor- mal Form (CNF), conjunctive and disjunctive neurons are introduced, which are the operations of Boolean algebra. These neurons are then combined to form more expressive constructs such as DNF and CNF functions.
Then the task becomes to assign weights to these neurons as flags indic- ating whether these operations are active or not. The problem of ILP can then be seen as finding an assignment to these membership boolean flags such that the resulting rules applied to the known facts entail all positive examples and rejects all negative examples. Moreover, by allowing these weights to be learnable, optimization techniques can be used to minimize the loss.
Capabilities of dILP vs dNL-ILP
There are mainly two capability differences between the two presented logic engines, both in favor of dNL-ILP. Firstly dILP restrict the number of rules for each learnable clause as well as the number of arguments per clause to at most two. While dNL-ILP is capable of inferring an arbitrary number of rules per predicate clause. Secondly, dNL-ILP is capable of inferring rules that are the inverse of a rule, i.e. in a similar fashion as performing theNOT