# How can an AI freely make decisions?

Suppose a deep neural network is created using Keras or Tensorflow. Usually, when you want to make a prediction, the user would invoke model.predict. However, how would the actual AI system proactively invoke their own actions (i.e. without the need for me to call model.predict)?

Neural networks, deep learning and other supervised learning algorithms do not "take actions" by themselves, they lack agency.

However, it is relatively easy to give a machine agency, as far as taking actions is concerned. That is achieved by connecting inputs to some meaningful data source in the environment (such as a camera, or the internet), and connecting outputs to something that can act in that environment (such as a motor, or the API to manage an internet browser). In essence this is no different from any other automation that you might write to script useful behaviour. If you could write a series of tests, if/then statements or mathematical statements that made useful decisions for any machine set up this way, then in theory a neural network or similar machine learning algorithm could learn to approximate, or even improve upon the same kind of function.

If your neural network has already been trained on example inputs and the correct actions to take to achieve some goal given those inputs, then that is all that is required.

However, training a network to the point where it could achieve this in an unconstrained environment ("letting it loose on the internet") is a tough challenge.

There are ways to train neural networks (and learning functions in general) so that they learn useful mappings between observations and actions that progress towards achieving goals. You can use genetic algorithms or other search techniques for instance, and the NEAT approach can be successful training controllers for agents in simple environments.

Reinforcement learning is another popular method that can also scale up to quite challenging control environments. It can cope with complex game environments such as Defense of the Ancients, Starcraft, Go. The purpose of demonstrating AI prowess on these complex games is in part showing progress towards a longer-term goal of optimal behaviour in the even more complex and open-ended real world.

State of the art agents are still quite a long way from general intelligent behaviour, but the problem of using neural networks in a system that learns how to act as an agent has much research and many examples available online.

• "However, training a network to the point where it could achieve this in an unconstrained environment ("letting it loose on the internet") is a tough challenge." And if you let it learn based on what they see in unconstrained environments, you can easily get things like Microsoft's Tay turning into a Nazi after spending less than 24 hours on Twitter. Dec 11, 2019 at 7:45

The short answer, i think, is that it cannot.

The AI system will only do, and it will only be good at the task that the programmer made it for. Of course you could have an AI that, for example, can trigger a prediction on the input with different models depending on some other variables, but that will still be based on what the programmer wrote, it will never be able to do or learn new unintended things. Like having the model.predict() for an image classification NN in a loop and only stop when it detects a dog and then use another model to predict the breed for example.

What you mentioned about "letting the AI lose on the network" usually is part of some concerns about AI that it could evolve, learn new actions and start acting on its own. But those people unknowingly are actually talking about a general AI or strong AI, an AI system that could be as smart as a human so it could act in its own too. But as far is a know at least, we are not even close to creating such a system.

• There have been plenty of examples of AIs doing unexpected things, but they are still constrained to the domain they are designed for. A Twitter bot may learn to be racist, but it will still only be able to post tweets; it won't be able to stab people. Dec 11, 2019 at 12:18

You invoke it in a loop. Imagine a digital assistant responding to voice queries. It might look something like this:

for(;;) {
var audio = RecordSomeAudio();
var response = model.predict(audio);
if(response.action == "SAYSOMETHING") {
PlaySomeAudio(response.output);
}
}


Note that the model gets invoked repeatedly and can decide in a given situation whether to respond or not. In a digital assistant context, part of the model would be to check for if the user raised a query (e.g. "Hey Google" etc.).